Approach :
We will be using 'length()' method to calculate length of String and 'toLowerCase()' method to convert lowercase string to lowercase.
Take a input from the user using Scanner class and then use 'toLowerCase()' method to convert the string to lowercase.
You can use 'toUpperCase()' to convert the String to UpperCase
Code :
import java.util.Scanner;
public class length {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter a String :-");
String str = sc.nextLine();
String LowStr = str.toLowerCase();
System.out.println("Length of String : "+str.length());
System.out.println("Original String : "+str);
System.out.println("Lowercase : "+LowStr);
}
}
Output :
Enter a String :-
ABHAY KUMAR
Length of String : 11
Original String : ABHAY KUMAR
Lowercase : abhay kumar
0 Comments
Ask Your Queries in the comments