Introduction
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'.
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'.
Create a new Java file named ISOControlChar.java in the ~/project directory by running the following command in the terminal:
touch ~/project/ISOControlChar.java
Now we will write the main method in the ISOControlChar.java file. The main method will read a character from the user and check if it is an ISO control character or not using the isISOControl(char ch) method.
import java.util.Scanner;
public class ISOControlChar {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
System.out.print("Enter any character: ");
char ch = sc.next().charAt(0);
if(Character.isISOControl(ch)){
System.out.println(ch + " is an ISO control character.");
} else {
System.out.println(ch + " is not an ISO control character.");
}
}
}
Compile the ISOControlChar class by running the following command:
javac ISOControlChar.java
Now, to run the program, enter the following command:
java ISOControlChar
In this lab, we learned how to use the isISOControl(char ch) method of the Java Character class to check if a character is an ISO control character or not. We also learned to create a Java program to test if a given character is an ISO control character or not.