String toUpperCase example

String toUpperCase method is used to converts all characters in a given string to upper case. String has 2 toUpperCase methods.

The first method takes a default Locale for converting the String to upper case, while in the second method we can explicitly give a Locale for the String to convert to upper case.
Lets see an example that covers both these methods.

String toUpperCase example


Please Note:
Before performing any operation on any dynamically generated String, check if the String is not null.
Else a NullPointerException is thrown.


1. String toUpperCase()- API

2. String toUpperCase(java.util.Locale)-API