uppercase in java | lowercase in java

Java program to convert string to lowercase and uppercase using String function

Here, we are supposed to create a source code that asks for String input from the user and displays the string by changing the String’s Case to both UpperCase and LowerCase.

The basic idea is to change the input string’s case using String functions <String>.toUpperCase() for upper case modification and <String>.LowerCase() for lower case modification.

Java Code:

/* Program to enter a string and display in both UpperCase and LowerCase using String function.*/

import java.util.*; class DisplayCase { public static void main() { Scanner inp=new Scanner(System.in); System.out.print("\n Enter String: "); String s=inp.nextLine();

System.out.println("\n Upper Case: "+(s.toUpperCase())); System.out.println("\n Lower Case: "+(s.toLowerCase()));

} }

Output:

Enter String: The Big Bang Theory

Upper Case: THE BIG BANG THEORY

Lower Case: the big bang theory

Enter String: FrIenDs

Upper Case: FRIENDS

Lower Case: friends