LAST UPDATED: NOVEMBER 24, 2020
Java Character isISOControl(char ch) Method
Java isISOControl(char ch)
is a part of Character
class. This method is used to check whether the specified character is an ISO control character or not.
A character is an ISO control character if its code lies in the range of '\u000'
through '\u001F'
or in the range of '\u007F'
through '\u009F'
.
Syntax:
public static boolean isISOControl(char ch)
Parameters:
The parameter passed is the character to be checked for ISO Control.
Returns:
Returns the boolean value true
if the specified character is an ISO control character else return false
.
Example 1:
Here, the characters are checked by using the isISOControl() method whether they are ISO Control 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.isISOControl(ch1);
boolean b2 = Character.isISOControl(ch2);
boolean b3 = Character.isISOControl(ch3);
boolean b4 = Character.isISOControl(ch4);
boolean b5 = Character.isISOControl(ch5);
System.out.println(ch1 +" is a ISO control?: "+b1);
System.out.println(ch2 +" is a ISO control?: "+b2);
System.out.println(ch3 +" is a ISO control?: "+b3);
System.out.println(ch4 +" is a ISO control? : "+b4);
System.out.println(ch5 +" is a ISO control?: "+b5);
}
}
g is a ISO control?: false
D is a ISO control?: false
# is a ISO control?: false
e is a ISO control? : false
8 is a ISO control?: 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.isISOControl(ch);
System.out.println(ch + " is an ISO Control? : "+b);
}
catch(Exception e)
{
System.out.println("Invalid Input!!");
}
}
}
Enter the character: ~
~ is an ISO Control? : false
**********************************
Enter the character: .
. is an ISO Control? : 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.