I want to change a String so that all the uppercase characters become lowercase, and all the lower case characters become uppercase. Number characters are just ignored.
so "AbCdE123" becomes "aBcDe123"
I guess there must be a way to iterate through the String and flip each character, or perhaps some regular expression that could do it.
Check each character, and use Character. isUpperCase / or Character. isLowerCase to test and reverse the capitalization.
String class in Java does not have reverse() method, however, the StringBuilder class has built-in reverse() method. StringBuilder class do not have toCharArray() method, while String class does have toCharArray() method.
toUpperCase(char ch) converts the character argument to uppercase using case mapping information from the UnicodeData file. Note that Character. isUpperCase(Character.
Apache Commons StringUtils has a swapCase method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With