Java Program to check a given input is alphabet or not

Java Program to check a given input is alphabet or not

In this tutorial you will be learning Writing Java Program to check a Given input is Alphabet or not.

For Example:

Example 1:

Suppose a given input is 10

Then the output should be “Given input is not an alphabet”.

Example 2:

And for the input “A” or any character

The output should be “Given input is an alphabet”.

Program To Check given input is Alphabet or not in Java

import java.util.*;
public class Main
{
  public static void main (String[] args)
  {
    System.out.println("Check if input is alphabet java");
    Scanner sc = new Scanner (System.in);
    System.out.println ("Enter a input");
    char ch = sc.next ().charAt (0);
     if (Character.isLetter(ch)) {
         System.out.println("Given input is an alphabet");
      }else {
         System.out.println("Given input is not an alphabet");
      }
  }
}

Output 1:

Check if input is alphabet java
Enter a input
we
Given input is an alphabet

Output 2:

Check if input is alphabet java
Enter a input
23
Given input is not an alphabet