首页 > 代码库 > 字符串的操作

字符串的操作

技术分享

  String string = new String("zxcvbnm");
            System.out.println("字符串长度:"+string.length());
            System.out.println("字符串全变成大写:"+string.toUpperCase());
            System.out.println("大写的与小写比较返回TRUE:"+string.equalsIgnoreCase("ZXCVBNM"));
            System.out.println("某一字符在字符串的位置:"+string.indexOf("c")+1);
            System.out.println("截取字符串:"+string.substring(3, string.length()));
            String string1 = new String(" zxcvbnm ");
            System.out.println("去除前导和后导空格:"+string1.trim());
      for (int i = 0; i < string.length(); i++) {
            System.out.println("第"+(i+1)+"个字符:"+string.charAt(i));

  技术分享

技术分享技术分享技术分享

字符串的操作