Open In App

Character.isISOControl() method with examples in Java

Improve
Improve
Like Article
Like
Save
Share
Report

The java.lang.Character.isISOControl() is an inbuilt method in java which determines if the specified character is an ISO control character or not. A character is considered to be an ISO control character if its code is in the range ‘\u0000’ through ‘\u001F’ or in the range ‘\u007F’ through ‘\u009F’. This method cannot handle supplementary characters. In order to support all the Unicode characters, including supplementary characters, the parameter can be on int datatype in the above method.

Syntax:

public static boolean isISOControl(data_type ch)

Parameters: The function accepts a single parameter ch which is mandatory. It specifies the character to be tested. The parameter can be of char or int datatype.

Return value: The function returns a boolean value. The boolean value is true if the character is an ISO control character or false otherwise.

Below programs illustrate the above method:

Program 1:




// java program to demonstrate
// Character.isISOControl() method
// when the parameter is a character
  
import java.lang.*;
  
public class gfg {
  
    public static void main(String[] args)
    {
  
        // create 2 char primitives c1, c2 and assign values
        char c1 = '-', c2 = '\u0017';
  
        // assign isISOControl results of c1
        // to boolean primitives  bool1
        boolean bool1 = Character.isISOControl(c1);
  
        if (bool1)
            System.out.println(c1 + " is an ISO control character");
        else
            System.out.println(c1 + " is not an ISO control character");
  
        // assign isISOControl results of c2
        // to boolean primitives  bool2
        boolean bool2 = Character.isISOControl(c2);
  
        if (bool2)
            System.out.println(c2 + " is an ISO control character");
        else
            System.out.println(c2 + " is not an ISO control character");
    }
}


Output:

- is not an ISO control character
 is an ISO control character

Program 2:




// java program to demonstrate
// Character.isISOControl(char ch) method
// when the parameter is an integer
import java.lang.*;
  
public class gfg {
  
    public static void main(String[] args)
    {
  
        // create 2 char primitives c1, c2 and assign values
        int c1 = 0x008f;
        int c2 = 0x0123;
  
        // assign isISOControl results of c1
        // to boolean primitives  bool1
        boolean bool1 = Character.isISOControl(c1);
        if (bool1)
            System.out.println(c1 + " is an ISO control character");
        else
            System.out.println(c1 + " is not an ISO control character");
  
        // assign isISOControl results of c2
        // to boolean primitives  bool2
        boolean bool2 = Character.isISOControl(c2);
        if (bool2)
            System.out.println(c2 + " is an ISO control character");
        else
            System.out.println(c2 + " is not an ISO control character");
    }
}


Output:

143 is an ISO control character
291 is not an ISO control character

Reference: https://docs.oracle.com/javase/7/docs/api/java/lang/Character.html#isISOControl(char)



Last Updated : 06 Dec, 2018
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads