字符串
- 字符串都是常量可以追加但是不能修改
- 字符串的值都存储在字符串常量池中
@Test
public void Test(){
String str=new String("我爱学习");
String str1="我爱学习";
String str2="我爱学习";
String str4="我爱"+"学习";
String str5="我爱";
String str6="学习";
String str7=str5+str6;
System.out.println(str==str2);
System.out.println(str1==str2);
System.out.println(str1==str4);
System.out.println(str1==str7);
String str8="asdasdsadsadsa";
System.out.println(str8.length());
System.out.println(str8.charAt(0));
System.out.println(str8.indexOf("a"));
System.out.println(str8.indexOf("ds",2));
System.out.println(str8.startsWith("as"));
System.out.println(str8.substring(5));
System.out.println(str8.substring(3,5));
String str9=str.replace("a", "abc");
String s1=" ss sss ";
System.out.println(s1);
String s2=s1.trim();
System.out.println(s2);
String s3="123";
String s4="456";
System.out.println(s3.concat(s4));
String s6="aaa-666-ccc-bbb";
String [] arr1=s6.split("-");
for (int i = 0; i < arr1.length; i++) {
System.out.println(arr1[i]);
}