In this section, we will learn what the Character toLowerCase() method is and how to use in Java.
What is Java Character toLowerCase() Method?
The `toLowerCase()` method is used to return the lowercased letter of the character that we set as the argument of this method.
Java toLowerCase() Method Syntax:
static char toLowerCase(char ch)
toLowerCase() Method Parameters:
The method takes one argument, and that is the character that we want to lowercase.
toLowerCase() Method Return Value:
The return value of this method is of type `char` and that is the lower-cased letter that we’ve set as its argument.
Note: if the target character is not a letter or is already a lower-cased letter, the character itself will be returned.
Example: using Character toLowerCase() method
public class Simple {
public static void main(String args[]) {
String s = "YOU NEVER KNOW WHAT WILL HAPPEN TOMORROW!";
for (char c: s.toCharArray()){
System.out.print(Character.toLowerCase(c));
}
}
}
Output:
you never know what will happen tomorrow!