jeudi 14 décembre 2017

Make char uppercase within String

I want to make the vowels of a String uppercase. Here's the method for it:

public static String LetterChanges(String str) {

        char[] strChar = str.toCharArray();

        for (int i =0; i < str.length(); i++){
            char ch = str.charAt(i);

            if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u'){
                Character.toUpperCase(ch);
                str.replace(strChar[i], ch);
            }
        }
     return str;
}

That "if" statement will pick up a vowel, but I can't figure out how to make it uppercase. IntelliJ says the results of .toUpperCase and .replace are both ignored. Could somebody please explain why those methods are ignored, and also perhaps point me in the right direction with this code?

Aucun commentaire:

Enregistrer un commentaire