Java: Convert a given string into lowercase
Java Basic: Exercise-59 with Solution
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.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/java-exercises/basic/java-basic-exercise-59.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics