.toUpperCase()
Anonymous contributor
Anonymous contributor1 total contribution
Anonymous contributor
Published Feb 13, 2023
Contribute to Docs
The .toUpperCase()
method converts all lowercase letters of a string to uppercase and returns a new string.
Syntax
string.toUpperCase();
Where string
is the string in which all lowercase letters are converted to uppercase.
The .toUpperCase()
method returns a new string consisting of the upper case form of the letters in the original string. To use the new upper case string, the returned string must be assigned to a variable.
Example
The following example applies the .toUpperCase()
method to the given text:
// MyClass.javapublic class MyClass {public static void main(String[] args) {String text = "Hello World";String textUp = text.toUpperCase();System.out.println(text);System.out.println(textUp);}}
This will print the following output:
Hello WorldHELLO WORLD
All contributors
- Anonymous contributorAnonymous contributor1 total contribution
- Anonymous contributor
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.