347
In this example we show you how to convert a string to lowercase in Java
Example
We will take input from the user
We will then use the built-in function toLowerCase() on the given string and display the result.
import java.util.Scanner; public class JavaApplication1 { private static Scanner myScanner; public static void main(String[] args) { String myString; myScanner= new Scanner(System.in); System.out.print("\nPlease Enter String = "); myString = myScanner.nextLine(); String lowString = myString.toLowerCase(); System.out.println("\nThe Lowercase String = " + lowString); } }
Here is a test run
run: Please Enter String = THIS IS A TEST stRIng The Lowercase String = this is a test string