java字符串

String s= "helloworld";
        System.out.println(s.length());
        System.out.println(s.charAt(4));
        char n = s.charAt(4);
        System.out.println(n);
        System.out.println(s.indexOf("o",5));
        System.out.println(s.substring(0));
        System.out.println(s.substring(0,s.length()));
        char[] ch = s.toCharArray();
        for (int i = 0 ; i 
int[] arr = {1,2,3};
String s="";
s+="[";
for (int i =0; i 
        String maxString = "woaijavawozhenaijavawozhendeaijavawozhendehenaijavaxinbuxinwoaijavagun";

        String minString = "java";
        int count = 0;
        int index;
        while ((index=maxString.indexOf(minString))!=-1)
        {
            count++;
            maxString = maxString.substring(index + minString.length());
        }
        System.out.println(count);
  • 将一个数字字符串转换成逗号分隔的数字串,即从右边开始每三个数字用逗号分隔


    java字符串_第1张图片

Scanner scanner = new Scanner(System.in);

String shu = scanner.next();

String y =shu.substring(shu.length()-3,shu.length());
String r =shu.substring(shu.length()-6,shu.length()-3);
String h =shu.substring(0,shu.length()-6);
        System.out.println(h+","+r+","+y);

你可能感兴趣的:(java字符串)