Share on Google+Share on Google+

java.lang.String.toUpperCase()

Ads
toUpperCase() method of string class coverts all the string character into uppercase letters.

As the method name suggest "toUpperCase()" it is used to convert all the characters given into the string to upper case. This method is useful when you need the generated output into upper case for example while showing the user information..you can conver the first name and last name format into upper case using toUpperCase() string class method.

a simple String.toUpperCase() java example:

public class Uppercase

{

public static void main(String[] args)

{

String str = "convert to upper case java example.";

// to convert the string into Upper Case.

String upper = str.toUpperCase();

// Display the two strings for comparison.

System.out.println("Orignal Value = " + str);

System.out.println("Changed to UpperCase = " + upper );

}

}

the output is:

Orignal Value = convert to upper case java example.

Changed to UpperCase = CONVERT TO UPPER CASE JAVA EXAMPLE. 

Example Code

toUpperCase() Method In Java

Advertisements

Ads

Posted on: March 22, 2005 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Ads

Advertisement