String:
1.
String底层存放的是字节数据,所以将其它数据转换成字节数据进行存储.
2.直接创建也是new了一个对象.
对于基本类型来说,是进行数值的比较(如int,char,double数的)
对于引用类型来说,==是进行地址值的比较(如String,Integer,Double)
字符串常量池:直接用双引号创建的字符串,就存放在字符串常量池中.
4.字符串内容进行比较:
String str1=“Hello”;
String str2=“Hello”;
System.out.println(str1.equals(str2));//true
System.out.println(str1.equals(“Hello”));//true
char[]charArray={‘H’,‘e’,‘l’,‘l’,‘o’};
String str3=new String(charArray);
System.out.println(str1.equals(str3));//true
String str4=“hello”;
str1.equalsIgnoreCase(str4);//忽略大小写进行比较,true
4.String 获取相关方法:
字符串一旦内容改变都是创建了新的字符串.
concat:也相当于用+将字符串拼接起来.
5.字符串截取方法(获得子字符串):
6.字符串转换相关方法.
字符数组的.length没有()的
String.length()包含有括号.
7.字符串切割方法:
8.例子: