1.String不是8种基本类型中的一种,String是Object,其默认值是null
2.String不可变,是final的,当对 String的对象进行拼接等操作的时候都是生成的新的String对象
3.new String( )或者new String(”")是创建了一个空字符串,其值并不是null
4.常量池中的字符串常量解析期间确定,且只有一份拷贝;new String( )出来的字符串不是常量,不放在常量池中,有自己的地址空间
5.String的intern( )方法扩充常量池:当一个String实例调用intern方法时,如果常量池中有相同unicode的字符串常量,则返回其引用;如果没有,增加一个unicode为该实例的String常量, 并返回其引用
6.一个实例:
String str0 = “flynewton”;
String str1 = “flynewton”;
String str2 = “fly” + “newton”;
String str3 = new String(”flynewton”);
System.out.println(str0 == str1); //true
System.out.println(str0 == str2); //true
System.out.println(str0 == str3); //false
str3.intern();
System.out.println(str0 == str3); //false
System.out.println(str0 == str3.intern()); //true