toLowerCase() Java - How to convert lowercase to uppercase
toLowerCase() in Java
The method called toLowerCase() converts all letters into lowercase. For example, the String "LIFE IS GREAT" will be converted into "life is great".
Syntax:
1 |
public String toLowerCase() |
How To Call the Method:
1 |
String result = str.toLowerCase(); |
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
public class Test { public static void main(String args[]){ String str = "I love JAVA"; String result = str.toLowerCase(); System.out.println("Result: " + result); str = "TEXT 1 2 3"; result = str.toLowerCase(); System.out.println("Result: " + result); str = "vertex"; result = str.toLowerCase(); System.out.println("Result: " + result); } } |
If you run this code on your computer, you will see the following in the console:
Commentary:
We have applied the method called toLowerCase to 3 Strings:
- "I love JAVA"
- "TEXT 1 2 3"
- "vertex"
As a result:
- "I love JAVA" was converted into "i love java"
- "TEXT 1 2 3" was converted into "text 1 2 3 "
- "vertex" was returned as "vertex", because initially it was already lowercase.
* The method toLowerCase() has another realization - with the parameter Localе. Later on we will write a separate article on this.
That's if for this article. You can find more articles in our Java Tutorial for Beginners.