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 :

[table]
DataType|Parameter|Description
N/A|N/A|N/A
[/table]

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 :