Java Program to check whether the entered value is ASCII 7 bit alphabetic uppercase

Java 8Object Oriented ProgrammingProgramming

To check whether the entered value is ASCII 7-bit alphabetic uppercase, check the character from ‘A’ to ‘Z’.

Here, we have a character.

char one = 'T';

Now, we have checked a condition with if-else to check for uppercase character from ‘A’ to ‘Z’

if (one >= 'A' && one <= 'Z') {
   System.out.println("Given character is in uppercase!");
} else {
   System.out.println("Given character is not in uppercase!");
}

Example

 Live Demo

public class Demo {
   public static void main(String []args) {
      char one = 'T';
      System.out.println("Character: "+one);
      if (one >= 'A' && one <= 'Z') {
         System.out.println("Given character is in uppercase!");
      } else {
         System.out.println("Given character is not in uppercase!");
      }
   }
}

Output

Character: T
Given character is in uppercase!

Let us see another example −

Example

 Live Demo

public class Demo {
   public static void main(String []args) {
      char one = 'e';
      System.out.println("Character: "+one);
      if (one >= 'A' && one <= 'Z') {
         System.out.println("Given character is in uppercase!");
      } else {
         System.out.println("Given character is not in uppercase!");
      }
   }
}

Output

Character: e
Given character is not in uppercase!
raja
Published on 10-Dec-2018 11:58:21
Advertisements