java 驼峰转空格并且首字母大写(ChatGPT回答)

ChatGpt给出的答案.就是牛.

	public static List<String> splitCamelCase(String input) {
        return Arrays.asList(input.split("(?=[A-Z])"));
    }
    
    public static String capitalize(String input) {
        return input.substring(0, 1).toUpperCase() + input.substring(1);
    }
    
    public static String camelCaseToTitleCase(String input) {
        List<String> words = splitCamelCase(input);
        for (int i = 0; i < words.size(); i++) {
            words.set(i, capitalize(words.get(i)));
        }
        return String.join(" ", words);
    }

java 驼峰转空格并且首字母大写(ChatGPT回答)_第1张图片

你可能感兴趣的:(java,开发语言)