How to convert a String to lowercase in Java

In this blog post, I will be explaining how you can convert a String to lowercase in Java. Consider the following code snippet:

 

</pre>package learnjava.strings;public class StringLowerCaseDemo {public static void main(String[] args) {String str = "Hello World";str = str.toLowerCase();System.out.println(str);}}<pre>

 

There is a String.toLowerCase method. This converts the String object on which it is invoked to lowercase and returns the converted String. So when you run the above code, you will get the following output:

hello world

Comments

Popular posts from this blog

How to check if a Date is before or after another Date

Java 11 String enhancements with examples

How to add Maven dependencies via Eclipse