Java: Convert a given string into lowercase
Convert to Lowercase
Write a Java program to convert a string into lowercase.
Pictorial Presentation: String to Lowercase
Sample Solution:
Java Code:
import java.util.*;
public class Exercise59 {
public static void main(String[] args) {
// Create a Scanner object for user input
Scanner in = new Scanner(System.in);
System.out.print("Input a String: ");
// Read a string from the user
String line = in.nextLine();
// Convert the string to lowercase
line = line.toLowerCase();
// Print the lowercase version of the input string
System.out.println(line);
}
}
Sample Output:
Input a String: THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. the quick brown fox jumps over the lazy dog.
Flowchart:
Java Code Editor:
Previous: Write a Java program to capitalize the first letter of each word in a sentence.
Next: Write a Java program to find the penultimate (next to last) word of a sentence.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics