方法如下
String str = "Hello Java!";
System.out.println(str.length());
System.out.println(str.indexOf('J'));
System.out.println(str.indexOf('j'));
System.out.println(str.charAt(0));
System.out.println(str.replace('J', 'W'));
System.out.println(str.replace('a', 'b'));
System.out.println(str.replace("Java", "World"));
System.out.println(str.replace("Jbvb", "World"));
String str2 = " Hello! ";
System.out.println(str2.trim());
String str3 = "Hello,This,is,Java";
String[] arrStr = str3.split(",");
System.out.println(Arrays.toString(arrStr));
byte[] bytes = str.getBytes();
System.out.println(Arrays.toString(bytes));
System.out.println(str.toLowerCase());
System.out.println(str.toUpperCase());
System.out.println(str.substring(0,5));
System.out.println(str.substring(6,10));
String str4 = "Hello";
String str5 = "Hello";
String str6 = "Java";
System.out.println(str4.equals(str5));
System.out.println(str4.equals(str6));