//今天主要写了一下关于==与equal的用法和比较。注意的是地址值与内容的区别。
class AboutEquals
{
public static void main (String[] args)
{
String str1 = "Hello";
String str2 = "Hello";
if (str1 == str2)
{
System.out.println("相等");
}else {
System.out.println("不相等");
}
String str3 = new String("hello");//新new的空间
String str4 = new String("hello");
if (str3 = str4)
{
System.out.println("相等");
}else{
System.out.println("不相等");
}
if (str3.equals(str4))
{
System.out.println("相等");
}else{
System.out.println("不相等");
}
}
}