Quick Java code snippet to change case of a String in Java. It uses toUpperCase()
and toLowerCase()
methods present in java.lang.String class to convert the case.
public class StringCase { public static void main(String args[]) { String str = "This code snippet is brought you by Java Techhig"; // toUpperCase() method converts the complete string in upper case String strUpper = str.toUpperCase(); // toLowerCase() method converts the complete string in lower case String strLower = str.toLowerCase(); // printing changed case string System.out.println("Upper Case: " + strUpper); System.out.println("Lower Case: " + strLower); } }
