Java String toUpperCase() method example

HQ » Java Tutorial » java.lang » String » toUpperCase() method example
Java String toUpperCase() method example 2018-02-19T13:10:35+00:00

java.lang.String toUpperCase()

Description :

This java tutorial shows how to use the toUpperCase() method of String class of java.lang package. This method returns a new String object which is the original string in upper case. The toUpperCase() method of String class simply used in conversion of String into upper case.

Method Syntax :

public String toUpperCase()

Parameter Input :

DataType Parameter Description
N/A N/A N/A

Method Returns :

This String toUppercase() method returns a new String object which is just the String equivalent in upper case.

Compatibility Version :

Since the beginning

Exception :

N/A

Discussion :

Since a String can never be changed once instantiated, thus a new string object variable is required to hold the new string during the conversion to uppercase. This method is helpful especially if we are comparing and storing data which comes from different systems.

Java Code Example :

This example source code demonstrates the use of toUpperCase() method of String class.

Sample Output :

Running the toUpperCase() method example source code of String class will give you the following output

string toUpperCase method example

string toUpperCase method example

Exception Scenario :

N/A

Similar Method :

  • java.lang.String toLowerCase()
  • java.lang.String toLowerCase(Locale locale)

Suggested Reading List :

 

Contact Info

Singapore

Our Goal

JavaTutorialHQ aims to to be The Ultimate Guide on Java with hundreds of examples from basic to advance Topics.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close