怎样判断字符串内容是否相等?
字符串类常见的方法:
public boolean equals(Object anObject) 比较字符串内容是否相等
package zifuchuan; public class StringDemo7 { public static void main(String[] args) { // TODO Auto-generated method stub String a=new String("lishuo"); String b=new String("lishuo"); //判断内容想等 System.out.println(a.equals(b)); //判断对象相等 System.out.println(a==b); //字符串类比较内容相等用"equals()"方法,比较对象相等用"==" } }