equals比较的是两个对象值是否相等,如果没有被重写,比较的是对象的引用地址是否相同;
==用于比较基本数据类型的值是否相等,或比较两个对象的引用地址是否相等;
String helloword= new String("helloword");
String helloword1 = new String("helloword");
System.out.println(helloword.equals(helloword1)); //重写了了,⽐比较的是值,输出结果为true
System.out.println(helloword== helloword1); //⽐比较的是引⽤用地址,输出结果为false
//⽐比较基本类型的值
int age = 10;
int age1 = 10;
System.out.println(age == age1); //输出为true