String

作者: 青丝如梦 | 来源:发表于2020-04-14 17:58 被阅读0次

    String 转 String数组:

            String str = "hello";
            String[] split = str.split("");
    

    String 首字母转大写:

    public static String captureName(String name) {
       //   name = name.substring(0, 1).toUpperCase() + name.substring(1);
       //   return  name;
            char[] cs=name.toCharArray();
            cs[0]-=32;
            return String.valueOf(cs);
     }
    

    字符串替换:

        public static void main(String[] args) {
            String str = "hello %s";
            String format = String.format(str, "world");
            System.out.println(format);
        }
    

    输出:

    Connected to the target VM, address: '127.0.0.1:50025', transport: 'socket'
    hello world
    Disconnected from the target VM, address: '127.0.0.1:50025', transport: 'socket'
    
    Process finished with exit code 0
    

    相关文章

      网友评论

          本文标题:String

          本文链接:https://www.haomeiwen.com/subject/ewtbkftx.html