怎样获取一个对象的HashCode地址值
2016-11-24 16:10
344 查看
package test;
import java.util.HashSet;
import java.util.Set;
public class TestB {
@SuppressWarnings({ "rawtypes", "unchecked" })
public static void main (String[] args) {
TestB tb= new TestB(); //随便获得一个类本身的 对象
List list = new ArrayList();
//list.add("2");
Map<K, V> m = new HashMap();
Set s = new HashSet<>(); //zz在自己定义一个任意对象这里选集合型Hashset的对象
//s.add("1");
int b = s.hashCode(); //由此看出直接通过hashCode(); 就能获得地址值在随便用个整形变量接收并输出就ok了
int a
=tb.hashCode(); //此处需注意set对象 不存内容哈希值为0;
int c = list.hashCode(); //list不存时为1
int d = m.hashCode(); // map不存时为0
System.out.println(a);
System.out.println(b);
System.out.println(c);
System.out.println(d);
}
}
import java.util.HashSet;
import java.util.Set;
public class TestB {
@SuppressWarnings({ "rawtypes", "unchecked" })
public static void main (String[] args) {
TestB tb= new TestB(); //随便获得一个类本身的 对象
List list = new ArrayList();
//list.add("2");
Map<K, V> m = new HashMap();
Set s = new HashSet<>(); //zz在自己定义一个任意对象这里选集合型Hashset的对象
//s.add("1");
int b = s.hashCode(); //由此看出直接通过hashCode(); 就能获得地址值在随便用个整形变量接收并输出就ok了
int a
=tb.hashCode(); //此处需注意set对象 不存内容哈希值为0;
int c = list.hashCode(); //list不存时为1
int d = m.hashCode(); // map不存时为0
System.out.println(a);
System.out.println(b);
System.out.println(c);
System.out.println(d);
}
}
相关文章推荐
- 怎样获取一个对象的HashCode地址值
- 怎样获取一个集合中不同对象的同一个属性?
- 怎样获取一个表中所有字段的信息
- 怎样调用动态获取的自定义对象的方法
- 一个小例子(sql获取刚插入数据库中对象的主键)
- 怎样删除一个集合中的对象
- 怎样得到一个方法的caller对象
- 蛙蛙推荐:怎样获取一个表中所有字段的信息
- 怎样获取session中的保存的对象的值:
- js中获取一个对象中包含的所有属性及属性值
- ef学习杂记4:怎样直接删除一个对象而无需检索它
- js通过Class Name获取一个对象的数组
- 怎样获取一个表中所有字段的信息
- 怎样写一个获取数据函数:用TCP/IP通讯,向服务端发送命令,并从服务端获得返回数据.
- 怎样持久化一个对象
- 已知一个一维数组:BYTE imageArray[width * height], 怎样在VC++2008的MFC中,用GDI+,创建一个Bitmap对象,与该数组建立关联?
- 怎样调用动态获取的自定义对象的方法
- 蛙蛙推荐:怎样获取一个表中所有字段的信息
- js 获取一个对象中的所有属性
- UIAlert 怎样多个实例化对象使用同一个delegate