各位大哥,简单的问题,小弟急等(100分)
public class temp
{
public static void main(String args[])
{
String str1=new String("hello");
String str2=new String("hello");
System.out.println(str1==str2);
System.out.println(str1!=str2);
str1="hello";
str2="hello";
System.out.println(str1==str2);
System.out.println(str1!=str2);
}
}
运行结果为什么是
false
true
true
false
上面到底比较的是什么?
还有==和equals()方法有什么不同,他们比较的分别是什么?
先谢过各位了