Java String equals()方法,
equias()方法用于将字符串与指定对象作比较。
String类重写了equias方法用与比较两个字符串是否相等。
而"=="是相等关系运算符,
在基本数据类型中:比较的是内容;
再引用类型数据中;比较的是对象所在的地址;
所以"=="与equals()方法
String a="hello"; //直接创建
String b="hello"; //直接创建
String c= a;
String d=new String("hello");//String 对象创建
String e=new String("hello");//String 对象创建
a==a;//true 相同的引用地址
a==b;//true a,b 都在公共池中 ,引用第支相同
a==c;//true 相同的引用地址
a==d;//false 引用地址不同
a==e;//false 堆中不同的引用地址
a.equals(b);//true 内容相同
a.equals(d);//true 内容相同
a.equals(e);//true 内容相同