Java String toUpperCase() and toLowerCase() Example
This Snippet is coded by a user inOnline java Compiler. You can see and run this code too.
زبان: Java
This Java code demonstrates the use of the toUpperCase() and toLowerCase() methods on a String object. When you run the program, it prints the string 'Hello World' in all uppercase letters and then in all lowercase letters.
These methods return a new string with the case converted; the original string remains unchanged. They are useful for case-insensitive comparisons, formatting output, and data normalization.
To use this code, save it as MyClass.java, compile with javac MyClass.java, and run with java MyClass.