Java String - Changing Case

by Dan Bunker

 

Java String toLowerCase() and toUpperCase()

 

When you need to compare two strings together it's often a good idea to convert each of the strings to either all upper case or all lower case so your test for equality can pass easier. The Java String class provides two method to do this. They are the toUpperCase() and toLowerCase() methods on the String Class object. These methods will take alpha characters and convert them to either upper or lower characters appropriately while leaving special characters and numbers alone.