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;
}

相关文章:

  • 2021-11-06
  • 2021-12-12
  • 2021-08-05
  • 2022-12-23
  • 2021-10-09
  • 2021-11-18
  • 2021-07-24
猜你喜欢
  • 2021-07-05
  • 2021-11-14
  • 2021-09-16
  • 2022-01-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案