1 import java.util.Collections; 2 3 import static com.sun.org.apache.xml.internal.security.keys.keyresolver.KeyResolver.length; 4 //java字符串不会改变,除非重新赋值 5 public class 字符串 { 6 public static void main(String[] args) { 7 String str = "44"; 8 int num = Integer.parseInt(str); 9 str = String.valueOf(num); 10 11 str = "dfa,sdf,adsf,asd,fasd,fas,df"; 12 String[] strings = str.split(","); 13 str = String.join(",", strings); 14 15 //左闭右开区间 16 String string = str.substring(3,6); 17 18 char c = string.charAt(1); 19 int d = string.compareTo(string); 20 String ss = string.concat(string); 21 boolean b = ss.contains("a"); 22 b = ss.startsWith("s"); 23 b = ss.endsWith("s"); 24 b = ss.isEmpty(); 25 26 b = ss.matches("a"); 27 28 ss = ss.replaceAll("sf" ,"asdf"); 29 ss = ss.replaceFirst("sf" ,"asdf"); 30 31 char[] chars = ss.toCharArray(); 32 33 ss = ss.toLowerCase(); 34 ss = ss.toUpperCase(); 35 ss = ss.trim(); 36 37 //StringBuilder 38 39 StringBuilder stringBuilder = new StringBuilder(""); 40 stringBuilder.append("sdf"); 41 int aa = stringBuilder.capacity(); 42 int bb = stringBuilder.length(); 43 44 stringBuilder.delete(1, 2);//左闭右开 45 46 stringBuilder.reverse(); 47 stringBuilder.deleteCharAt(1); 48 stringBuilder.insert(0, "0000"); 49 50 } 51 }