Hi, I was wondering if anyone could help me to create a java method to changing the uppercase letters to lowercase and visa versa in a string using a for-loop. Thanks.
changing the uppercase letters to lowercase and visa versa in a string
Collapse
X
-
Well, there are already some functions in the String class that do this...like toLowerCase() and toUpperCase() ...
But if you must write your own, you can use a for loop and the replace() method, along with Character.java's toLowerCase(cha r) or toUpperCase(cha r), to replace every lowercase letter with its uppercase equivalent (or vice versa).
Comment