Java String toUpperCase() Method
We have mentioned above, and also the name of the method says it all. With this method, we are creating an uppercase version of the string literal. Let’s have a simple program to understand the output of the method →
public class StringMethods {
public static void main(String[] args) {
String exampleString = “this is some text in upper case!”;
System.out.println(exampleString.toUpperCase());
System.out.println(exampleString);
}
}
If we try to run this program, we can see that the first output is the uppercase version of the string created above. But again, the example string is not pointing to the uppercase version itself, but still, it is pointing to the same string which was created before, which can be clearly witnessed from the output.
Again, if we do something like we have done previously, which is reassigning the string variable to point to the uppercase version object. So this is not a surprise for you anymore. We now know the things.
So, you can take some references from the previous program which we did while we understood the toLowerCase() method, and create a similar program for this method too.