Check whether a character is Lowercase or not in Java

Java 8Object Oriented ProgrammingProgramming

To check whether a character is in Lowercase or not in Java, use the Character.isLowerCase() method.

We have a character to be checked.

char val = 'q';

Now let us use the Character.isLowerCase() method.

if (Character.isLowerCase(val)) {
   System.out.println("Character is in Lowercase!");
}else {
   System.out.println("Character is in Uppercase!");
}

Let us see the complete example now to check for Lowercase in Java.

Example

 Live Demo

public class Demo {
   public static void main(String []args) {
      System.out.println("Checking for Lowercase character...");
      char val = 'q';
      System.out.println("Character: "+val);
      if (Character.isLowerCase(val)) {
         System.out.println("Character is in Lowercase!");
      } else {
         System.out.println("Character is in Uppercase!");
      }
   }
}

Output

Checking for Lowercase character...
Character: q
Character is in Lowercase!
raja
Published on 12-Nov-2018 12:16:30
Advertisements