将"goOd gooD stUdy dAy dAy up"每个单词的首字母转换成大写其余还是小写字母

public class zuoye2 {
    public static void main(String[] args) {
        String str = "goOd gooD stUdy dAy dAy up";
        str = convertStandard(str);
        System.out.println(str);
 
    }
 
    private static String convertStandard(String str) {
        String strStandard = "";
        String[] strs = str.split(" ");
        for(String s : strs){
            s = s.toLowerCase();
            String first = s.substring(0, 1).toUpperCase();
            s = first + s.substring(1, s.length());
            strStandard = strStandard + s + " ";
        }        
        return strStandard;
    }
}
原文地址:https://www.cnblogs.com/a709898670/p/9414452.html