In this program, we are going to determine if the given character is Uppercase or Lowercase alphabet. We have two different approaches:

  1. Using ASCII value range
  2. Using Character class

See also: Find ASCII value of a character

Using ASCII value range

If the ASCII value of a character lies between 65 (A) to 90 (Z) then it is an uppercase character or if the character’s ASCII value lies between 97 (a) to 122 (z) then it is a lowercase character.

See the flow diagram:

Program

import java.util.Scanner;

public class LowerUpperCase {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        System.out.println("Enter any caracter : ");
        char ch = scanner.next().charAt(0);

        if(ch >= 'A' && ch <= 'Z') {

            System.out.println(ch + " is UPPERCASE alphabet.");

        } else if(ch >= 'a' && ch <= 'z') {

            System.out.println(ch + " is LOWERCASE alphabet.");

        } else {
            
             System.out.println(ch + " is not an alphabet.");

        }

    }
}

Output

Enter any caracter : k
k is LOWERCASE alphabet.

Using Character class

Java has built-in wrapper class Character available in java.lang package. Here we are using static class isUpperCase() and isLowerCase() of Character class to determine the alphabet case.

Program

import java.util.Scanner;

public class LowerUpperCase {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        System.out.println("Enter any caracter : ");
        char ch = scanner.next().charAt(0);

        // Using character class
        if (Character.isUpperCase(ch)) {
            System.out.println(ch + " is UPPERCASE alphabet.");
        } else if (Character.isLowerCase(ch)) {
            System.out.println(ch + " is LOWERCASE alphabet.");
        } else {
            System.out.println(ch + " is not an alphabet.");
        }
        
    }
}

Output

Enter any caracter : K
K is UPPERCASE alphabet.