Case Conversions

Java-Case Conversions

Case Conversions

As the Java language is case sensitive, it differentiates uppercase letters from lowercase letters. The String class provides two methods, namely toLowerCase( ) and toUpperCase( ) to facilitate case conversions. While the toLowerCase( ) method converts all the letters of the given string to lower case, the toUpperCase( ) method does just the opposite.

Program

Case Conversions


Program Source

public class Javaapp {

    public static void main(String[] args) {
        
        String str1 = "AbCdEfGh";
        
        String str2 = str1.toUpperCase();
        
        String str3 = str2.toLowerCase();
        
        System.out.println("str1 -> "+str1);
        System.out.println("str2 -> "+str2);
        System.out.println("str3 -> "+str3);
    }
}

Leave a Comment