

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
isLetterOrDigit() method in Java
The isLetterOrDigit() method in Java returns TRUE if the entered value is a letter or digit.
We have the following character.
char val ='P';
Now, let us check for letter or digit using if-else decision-making statement.
if (Character.isLetterOrDigit(val)) { System.out.println("Value is a letter or digit!"); } else { System.out.println("Value is neither a letter nor a digit!"); }
The following is an example.
Example
public class Demo { public static void main(String []args) { char val ='P'; System.out.println("Value: "+val); if (Character.isLetterOrDigit(val)) { System.out.println("Value is a letter or digit!"); } else { System.out.println("Value is neither a letter nor a digit!"); } } }
Output
Value: P Value is a letter or digit!
Let us see another example.
Example
public class Demo { public static void main(String []args) { char val ='^'; System.out.println("Value: "+val); if (Character.isLetterOrDigit(val)) { System.out.println("Value is a letter or digit!"); }else { System.out.println("Value is neither a letter nor a digit!"); } } }
Output
Value: ^ Value is neither a letter nor a digit!
- Related Questions & Answers
- Collections.replaceAll() method and List.replaceAll() method in Java
- Method overloading in Java
- Method overriding in Java
- clone() method in Java
- Integer.lowestOneBit() method in Java
- Integer.numberOfLeadingZeros() method in Java
- Integer.numberOfTrailingZeros() method in Java
- Integer.rotateLeft() method in Java
- Integer.signum() method in Java
- Integer.reverseBytes() method in Java
- BigInteger.isProbablePrime() method in Java
- Java static method
- Java toString() method.
- Java NumberFormat.getInstance() method
- Java NumberFormat.getCurrencyInstance() method
Advertisements