O'Reilly logo

Java™ Phrasebook by Timothy Fisher

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Making a String All Uppercase or All Lowercase

String string = "Contains some Upper and some
											Lower.";
											String string2 = string.toUpperCase();
											String string3 = string.toLowerCase();

These two methods transform a string into all uppercase or all lowercase letters. They both return the transformed result. These methods do not change the original string. The original string remains intact with mixed case.

A practical area in which these methods are useful is when storing information in a database. There might be certain fields that you always want to store as all uppercase or all lowercase. These methods make the conversion a snap.

Case conversion is also useful for processing user logins. The user ID field is normally considered to be a field that’s ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required