public class A {public static void main(String[] args) {// TODO Auto-generated method stubStringBuilder sb=new StringBuilder();//长度可变的字符串sb//可以往字符串里添加任何字符串的方法。sb.append("haha");sb.append('s').append("jjjxxx");//链式编程System.out.println(sb);//字符串的反转的方法sb.reverse();System.out.println(sb);//hahasjjjxxx//xxxjjjsahahString s1="hello";String s2="hello";System.out.println(s1==s2);String s3=new String("hello");//包里有string类。System.out.println(s1==s3);//false.==是比较地址值System.out.println(s1.equals(s3));//比较内容trueString s4="HELLO";//忽略大小写的方法String X1.equalsIgnoreCase(String X2);System.out.println(s4.equalsIgnoreCase(s1));//true//判断字符串以***开头System.out.println(s4.startsWith("H"));//true//判断字符串以***结尾System.out.println(s4.endsWith("LO"));//true//字符串的获取功能//1.获取长度System.out.println("s4的长度:"+s4.length());//5//****此处的长度是调用包里的方法。而数组的长度是其属性。//通过索引获取字符System.out.println(s4.charAt(0));//H//遍历s4for (int i = 0; i < s4.length(); i++) {System.out.print(s4.charAt(i));}//找出字符串里的字母出现的下标System.out.println();System.out.println(s4.indexOf("H"));//0//截取字符串System.out.println(s4.substring(1));//ELLOSystem.out.println(s4.substring(0, 2));//HE//第2个下标不会取到。不包括end//字符串的转换的功能//1.将字符串转换成数组char[]arr=s4.toCharArray();for(int i=0;i<arr.length;i++){System.out.print(arr[i]);}//HEllo//把字符串转换为小写System.out.println();System.out.println(s4.toLowerCase());//helloString s5="heLLoworld";//把字符串转换为大写System.out.println(s5.toUpperCase());//HELLOWORLD//去除两端的空格 String s6=" haha ";System.out.println(s6.trim());//hahaString s7=" haha haha haha ";System.out.println(s7.replace(" ", ""));//hahahahahahaString s8="aa,bb,cc";String[]brr=s8.split(",");for (int i = 0; i < brr.length; i++) {System.out.print(brr[i]);}//aabbcc//字符串的反转//s4="HELLO";System.out.println();for (int i = s4.length()-1; i >=0; i--) {System.out.print(s4.charAt(i));}//OLLEH}}