- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java program to find whether the given character is an alphabet or not
Read a character from user verify whether it lies between a and z (both small and capital). If it does it is an alphabet.
Example
import java.util.Scanner; public class AlphabetOrNot { public static void main(String args[]){ System.out.println("Enter a character :: "); Scanner sc = new Scanner(System.in); char ch = sc.next().charAt(0); if(((ch >= 'A' && ch <= 'Z')||ch >= 'a' && ch <= 'z') ){ System.out.println("Given character is an alphabet"); }else{ System.out.println("Given character is not an alphabet"); } } }
Output
Enter a character :: d Given character is an alphabet
Advertisements