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.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()));



Enter String: The Big Bang Theory


 Lower Case: the big bang theory

 Enter String: FrIenDs

 Upper Case: FRIENDS

 Lower Case: friends


Report Error/ Suggestion

Related Posts:

CopyRight © 2020

CopyRight © 2020