String s1 ="monkey1024";
String s2 =new String ("monkey1024");
System.out.println(s1.equals(s2)); // true
String s3 ="sadsadaasa";
String s4 ="woaini";
System.out.println(s3.charAt(6)); // 获取index位置的字符
System.out.println(s4.contains("aini")); // 判断字符串中是否包含ai
String s5 ="wangzherongyao1021";
System.out.println(s5.endsWith("1021")); // 判断是否以某个字符串结尾
System.out.println(s5.equalsIgnoreCase("WANGZHERONGYAO1021")); // 忽略大小写
String s6 ="abc";
byte [] b1 = s6.getBytes(); // 这个方法转换成byte数组
for (int i =0; i < b1.length ; i++) {
System.out.println(b1[i] +",");
}
String s7 ="sdsadawadwwf";
System.out.println(s7.indexOf("d")); // 取得字符在字符串的位置
System.out.println(s7.indexOf("s",1)); // 取得第二s字符的位置
System.out.println(s7.lastIndexOf("w")); // 从最后面找 找到了第一个w的位置就是10
System.out.println(s7.lastIndexOf("w" , 8));
System.out.println(s7.length()); // 字符串长度
String s8 ="woleasd";
System.out.println(s8.replaceAll("easd" , "wwww")); // 替换字符串中的元素
String s9 ="a,b,c,d";
String [] array19 = s9.split(","); // 拆分字符串把,拆掉
for (int y =0 ; y < array19.length ; y++) {
System.out.print(array19[y] +" ");
}
String s10 ="monkey";
System.out.println(s10.startsWith("mo")); // 判断是否以每个字符串开始的
System.out.println(s10.substring(2)); // 根据输入的索引位置截取子串
System.out.println(s10.substring(1,3));
String s11 ="a,b,c,d"; // 将字符串转换成char类型的数组
char [] array12 = s11.toCharArray();
for (int x =0 ; x < array12.length ; x++) {
System.out.println(array12[x]);
}
String s12 ="a,b,c,d";
System.out.println(s12.toUpperCase()); // 转换为大写
String s13 ="A,B,C,D";
System.out.println(s13.toLowerCase()); // 转换为小写
String s14 =" java good ok "; // 去除首尾空格 注意 不是去除中间空格
System.out.println(s14.trim());
Object o =new Object();
System.out.println(String.valueOf(o));