Scanner sc = new Scanner( System.in);
ch=sc.nextLine();
String []ss=new String[10];
ss=ch.split(" ");
int size=ss.length;
String d[]={"rong"};
if(ss[0]==d[0])
System.out.println(true);
System.out.println(false);
从键盘输入rong yu
为什么结果是false?
ch=sc.nextLine();
String []ss=new String[10];
ss=ch.split(" ");
int size=ss.length;
String d[]={"rong"};
if(ss[0]==d[0])
System.out.println(true);
System.out.println(false);
从键盘输入rong yu
为什么结果是false?
凡是计算得到的String都不会从字符串常量池中搜索,所以lz最后肯定是false