LAST UPDATED: NOVEMBER 24, 2020
Java Character isIdentifierIgnorable(char ch) Method
Java isIdentifierIgnorable(char ch)
method is a part of Character
class. This method is used to check whether the specified character can be considered as an ignorable character in Java or a Unicode identifier or not.
The characters which are considered as ignorable characters or Unicode identifier are:
- ISO control characters that are not whitespace.
'\u0000'
through '\u0008'
'\u000E'
through '\u001B'
'\u007F'
through '\u009F'
- all characters that have the
FORMAT
general category value.
Syntax:
public static boolean isIdentifierIgnorable(char ch)
Parameters:
The parameter passed is the character to be checked for the ignorable character.
Returns:
Returns the boolean value true
if the specified character is an ignorable character else return false
.
Example 1:
Here, the characters are checked whether they are ignorable characters or not.
public class StudyTonight
{
public static void main(String[] args)
{
char ch1 = 'g';
char ch2 = 'D';
char ch3 = '@';
char ch4 = 'e';
char ch5 = '8';
boolean b1 = Character.isIdentifierIgnorable(ch1);
boolean b2 = Character.isIdentifierIgnorable(ch2);
boolean b3 = Character.isIdentifierIgnorable(ch3);
boolean b4 = Character.isIdentifierIgnorable(ch4);
boolean b5 = Character.isIdentifierIgnorable(ch5);
System.out.println(ch1 +" is a ignorable?: "+b1);
System.out.println(ch2 +" is a ignorable?: "+b2);
System.out.println(ch3 +" is a ignorable?: "+b3);
System.out.println(ch4 +" is a ignorable?: "+b4);
System.out.println(ch5 +" is a ignorable?: "+b5);
}
}
g is a ignorable?: false
D is a ignorable?: false
@ is a ignorable?: false
e is a ignorable? : false
8 is a ignorable?: false
Example 2:
Here is a user-defined example where anyone using this code can put a value of his choice and get the equivalent output.
import java.util.Scanner;
public class StudyTonight
{
public static void main(String[] args)
{
try
{
System.out.print("Enter the character: ");
Scanner sc = new Scanner(System.in);
char ch = sc.next().charAt(0);
boolean b = Character.isIdentifierIgnorable(ch);
System.out.println(ch + " is a ignorable? : "+b);
}
catch(Exception e)
{
System.out.println("Invalid Input!!");
}
}
}
Enter the character: t
t is a ignorable? : false
*****************************
Enter the character: 2
2 is a ignorable? : false
Live Example:
Here, you can test the live code example. You can execute the example for different values, even can edit and write your examples to test the Java code.