Java program to convert given string to lower case

Views: 117   

Following program shows you how to convert given string to lower case.
In this program we get string from user and convert that string into lower case using toLowerCase()

import java.util.Scanner;

public class StringOperations2 {

    public static void main(String[] args) {

        String input;

        Scanner in = new Scanner(System.in);

        System.out.println("Please enter the string:");

        input = in.nextLine();

        String lowerCase = input.toLowerCase();

        System.out.println("Given string in lower case: " + lowerCase);

    }
}

Output:

Please enter the string:
HELLO WORLD
Given string in lower case: hello world
On By