objects类
![在这里插入图片描述](https://img-blog.csdnimg.cn/img_convert/30f832863ee2759f809b7d2dd75ca5cf.png#pic_center)
![在这里插入图片描述](https://img-blog.csdnimg.cn/img_convert/482cc2c1b613caf10abb118be58dfa95.png#pic_center)
![在这里插入图片描述](https://img-blog.csdnimg.cn/img_convert/e8922ccbfc928dcb09713575c83186fc.png#pic_center)
![在这里插入图片描述](https://img-blog.csdnimg.cn/img_convert/547d5d7209edabaf2b1193063e5ccf13.png#pic_center)
![在这里插入图片描述](https://img-blog.csdnimg.cn/img_convert/0b7f1c041036324436af41f7d4378a2e.png#pic_center)
```java
package Demo1;
import java.util.Objects;
public final class getClass {
private String name;
private int age;
// TODO Auto-generated constructor stub
public getClass(String name, int age) {
this.name = name;
this.age = age;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
@Override
public String toString() {
return "getClass{" +
"name='" + name + '\'' +
", age=" + age +
'}';
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
getClass getClass = (getClass) o;
return age == getClass.age && Objects.equals(name, getClass.name);
}
@Override
public int hashCode() {
return Objects.hash(name, age);
}
}
package Demo1;
public class TestgetClass {
public static void main(String[] args) {
//getClass 返回类型
getClass s1 = new getClass("luo",21);
getClass s2 = new getClass("luohz",22);
//判断s1s2是不是同一类型
//getClass
Class class1 = s1.getClass();
Class class2 = s2.getClass();
if (class1==class2){
System.out.println("一样类型");}
else{
System.out.println("不一样类型");}
//hashCode int类型
System.out.println(s1.hashCode());
System.out.println(s2.hashCode());
getClass s3 = s1;
System.out.println(s3);
//toString 字符类型
System.out.println(s1.toString());
System.out.println(s2.toString());
//equals 判断对象是否一致
System.out.println(s1.equals(s2));
getClass s4 = new getClass("luo",20);
getClass s5 = new getClass("luo",20);
System.out.println(s4.equals(s5));//flase 因为s4和s5在推里不同位置
//finalize 处理无用对象
}
}