This write-up will state the method character.toUpperCase() in Java.
What is Character.toUpperCase() in Java?
The “toUpperCase()” method in Java is utilized for converting the element or characters in uppercase. However, it can not modify the actual string.
How to Utilize the “toUpperCase()” in Java?
To use the “.toUpperCase()” method, check out the given syntax:
Here, the “toUpperCase()” method will convert the string into UpperCase.
Example 1: Convert LowerCase String to UpperCase in Java
To convert the lowercase string to uppercase, add the text by defining the string. To do so, follow the below-listed instructions:
- First, initialize a variable to add the text in the Java file. In this case, the “txt” variable is utilized.
- Next, the “.toUpperCase()” method converts the characters into uppercase.
- “System.out.println()” is utilized to display the output on the console:
It can be observed that all of the characters have been converted into UpperCase:
Example 2: Convert CamelCase to UpperCase in Java
You can also convert the lowercase as well as camelcase letters into the uppercase. To do so, the value of the initialize the variable is set as camel case:
Output
That’s all about converting characters to uppercase in Java.
Conclusion
In Java, you can use the “toUpperCase()” method for the purpose of converting elements or multiple strings in capital letters. This method can also be utilized for converting camelcase characters into uppercase. This post demonstrated the usage of the Character.toUpperCase() method in Java.