toString方法
主要是为了方便输出。
没有重写之前是属于Object类。
左边:全路径名,包括包名 getClass.getName
中间:@
右边:十六进制的哈希码值
alt + shift + s s
getClass方法
获取类的字节码文件
getName()获取类名
全路径名,包括包名
hashcode方法
hashcode是内存中的地址值,int类型
重写hashcode之后,两个相同的对象。地址值肯定相同。
两个不同的对象,地址值有可能相同。
student s = new student();
s.hashcode();
1
teacher t = new teacher();
t.hashcode();
1
因为hashcode的返回值是int类型的。有范围。