大文字⇔小文字の変換


        String line = sc.nextLine();
        String[] word = sc.nextLine().split("");
        
        for (String w : word) {
            if (line.contains(w)) {
                System.out.print(w);
            } else {
                if(Character.isUpperCase(w.charAt(0))) {
                    System.out.print(w.toLowerCase());
                } else {
                    System.out.print(w.toUpperCase());
                }
            }
        }

小文字にする場合
string.toLowerCase()

大文字にする場合
string.toUpperCase()



投稿日

カテゴリー:

, , , ,

投稿者: