cmain.java

来自「java的经典例子」· Java 代码 · 共 26 行

JAVA
26
字号
class CMain {
    public static String makeTitle(String name) {
        char[] buf = new char[name.length()];
        boolean title = true;
        name.getChars(0, name.length(), buf, 0);

        // Capitalize first letter of each word

        for (int i = 0; i < buf.length; i++) {
            if (title)
                buf[i] = Character.toTitleCase(buf[i]);
            else
                buf[i] = Character.toLowerCase(buf[i]);
            title = Character.isWhiteSpace(buf[i]);
        }
        return (new String(buf));
    }

    public static void main(String[] args) {
        if (args.length == 1)
            System.out.println(makeTitle(args[0]));
        else
            System.out.println(makeTitle("this is a tEst"));
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?