All for Joomla All for Webmasters

Java String toUpperCase

The java string toUpperCase() method returns the string in uppercase letter. In other words, it converts all characters of the string into upper case letter.

The toUpperCase() method works same as toUpperCase(Locale.getDefault()) method. It internally uses the default locale.


Signature

There are two variant of toUpperCase() method. The signature or syntax of string toUpperCase() method is given below:

  1. public String toUpperCase()
  2. public String toUpperCase(Locale locale)

The second method variant of toUpperCase(), converts all the characters into uppercase using the rules of given Locale.


Returns

string in uppercase letter.


Java String toUpperCase() method example

  1. public class StringUpperExample{
  2. public static void main(String args[]){
  3. String s1=“hello string”;
  4. String s1upper=s1.toUpperCase();
  5. System.out.println(s1upper);
  6. }}

 

Output:

HELLO STRING
PinIt
submit to reddit

Leave a Reply

Top