Character.isISOControl() method with examples in Java

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:

filter_none

edit
close

play_arrow

link
brightness_4
code

// 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");
    }
}

chevron_right


Output:

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

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

// 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");
    }
}

chevron_right


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)



My Personal Notes arrow_drop_up

Contented with little yet wishing for more

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.