How to convert a String to uppercase
Posted On
Posted By admin
In this blog post, I will be explaining how you can convert a String to uppercase. Consider the following code snippet:
package learnjava.strings; public class StringUpperCaseDemo { public static void main(String[] args) { String str = "Hello World"; str = str.toUpperCase(); System.out.println(str); } }
There is a String.toUpperCase method. This converts the String object on which it is invoked to uppercase and returns the converted String. So when you run the above code, you will get the following output:
HELLO WORLD
If you like this post, please do let me know via the comments box below. You can also connect with me via my Facebook Page or subscribe to my Youtube channel!