Java: Convert all the characters in a string to lowercase
29. Convert to Lowercase
Write a Java program to convert all characters in a string to lowercase.
Visual Presentation:
Sample Solution:
Java Code:
// Define a public class named Exercise29.
public class Exercise29 {
    
    // Define the main method.
    public static void main(String[] args) {
        // Declare and initialize a string variable.
        String str = "The Quick BroWn FoX!";
        // Convert the above string to all lowercase.
        String lowerStr = str.toLowerCase();
        // Display the original and lowercase strings for comparison.
        System.out.println("Original String: " + str);
        System.out.println("String in lowercase: " + lowerStr);
    }
}
Sample Output:
Original String: The Quick BroWn FoX! String in lowercase: the quick brown fox!
Flowchart:
For more Practice: Solve these Related Problems:
- Write a Java program to convert a string to lowercase without using the built-in toLowerCase() method.
 - Write a Java program to convert a mixed-case string to lowercase and then count the occurrences of each letter.
 - Write a Java program to convert a string to lowercase and compare it with another string for equality.
 - Write a Java program to transform a string to lowercase and then output the string in reverse.
 
Go to:
PREV : Char Array from String.
NEXT : Convert to Uppercase.
Java Code Editor:
Improve this sample solution and post your code through Disqus
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
