Java – Convert a String to Lowercase
To convert a string to lowercase in Java, call toLowerCase() method on the string object. The method returns a new String object with the characters in the original string transformed to lowercase letters.
The syntax to convert a string to lowercase is
</>
Copy
String.toLowerCase()
1. Convert string to lowercase in Java using String.toLowerCase()
In the following program, we have taken a string and shall convert it to lowercase using String.toLowerCase() method.
Java Program
</>
Copy
public class Example {
public static void main(String[] args){
String str = "ABcDefGH";
String result = str.toLowerCase();
System.out.println("Original String : " + str);
System.out.println("Lowercase String : " + result);
}
}
Output
Original String : ABcDefGH
Lowercase String : abcdefgh
Conclusion
In this Java Tutorial, we learned how to convert a String to lowercase, using String.toLowerCase() method.