java is 和 == ,以及equal

package string;

public class MemAddrChange {
public static void main(String[] args) {


// const 常量区, 堆区 new String() 从const区Copy 一份
String str1 = "hello";
String str2 = "hello";
String str3 =new String("hello");
System.out.println(str1==str3); //false
System.out.println(str1==str2); // == compare point addr,引用地址
System.out.println(str1.equals(str3)); // compare content of mem
}
}


class Dog{
int a =11;
}
posted @ 2020-01-21 23:54  不带R的墨菲特  阅读(638)  评论(0编辑  收藏  举报