本帖最后由 smile_joe 于 2013-4-20 19:21 编辑  
 
 
- public class Test1 {
 
 -         public static void main(String[] agrs) {
 
 -                 
 
 -                 Student s=new Student("tom",26);
 
 -                 int i=s.hashCode();
 
 -                 System.out.println(Integer.toHexString(i));
 
 -                 System.out.println(s);
 
  
-         
 
 -         
 
 -         }
 
 - }
 
 - class Student {
 
 -         
 
 -         String name;
 
 -         int age;
 
 -         Student() {}
 
 -         Student(String name,int age) {
 
 -                 this.name=name;this.age=age;
 
 -         }
 
 - }
 
 
  复制代码 在对象打点调用hashCode()得到的值,转成16进制(用Integer.toHexString)方法得到的字符与该对象的@后的地址值一样,那hashCode值是否能代表这个对象?... |