Character.isValidCodePoint() Method in Java with Examples
Last Updated :
06 Dec, 2018
Improve
The Character.isValidCodePoint() is an inbuilt method in java that determines whether the specified code point mentioned in the parameter is a valid Unicode code point value or not.
Syntax:
Java
Java
public static boolean isValidCodePoint(int codePoint)Parameters: The parameter codePoint is of Integer datatype and refers to the unicode code point that is to be tested. Return Values: This method returns true if the specified code point value is between MIN_CODE_POINT and MAX_CODE_POINT inclusive, false otherwise. Below Programs illustrates the use of Character.isValidCodePoint() method: Program 1:
// Java program to demonstrate the
// Character.isValidCodePoint() method
import java.lang.*;
public class gfg {
public static void main(String[] args)
{
// Create 2 int primitives c1, c2 and assign values
int c1 = 0x0125, c2 = 0x123fff;
boolean bool1 = Character.isValidCodePoint(c1);
boolean bool2 = Character.isValidCodePoint(c2);
String str1 = "c1 is a valid Unicode code point is " + bool1;
String str2 = "c2 is a valid Unicode code point is " + bool2;
// Print bool1, bool2 values
System.out.println(str1);
System.out.println(str2);
}
}
// Java program to demonstrate the
// Character.isValidCodePoint() method
import java.lang.*;
public class gfg {
public static void main(String[] args)
{
// Create 2 int primitives c1, c2 and assign values
int c1 = 0x0125, c2 = 0x123fff;
boolean bool1 = Character.isValidCodePoint(c1);
boolean bool2 = Character.isValidCodePoint(c2);
String str1 = "c1 is a valid Unicode code point is " + bool1;
String str2 = "c2 is a valid Unicode code point is " + bool2;
// Print bool1, bool2 values
System.out.println(str1);
System.out.println(str2);
}
}
Output:
Program 2:
c1 is a valid Unicode code point is true c2 is a valid Unicode code point is false
// Java program to demonstrate the
// Character.isValidCodePoint() method
import java.lang.*;
public class gfg {
public static void main(String[] args)
{
// Create 2 int primitives c1, c2 and assign values
int c1 = 0x0128, c2 = 0x123ddd;
boolean bool1 = Character.isValidCodePoint(c1);
boolean bool2 = Character.isValidCodePoint(c2);
String str1 = "c1 is a valid Unicode code point is " + bool1;
String str2 = "c2 is a valid Unicode code point is " + bool2;
// Print bool1, bool2 values
System.out.println(str1);
System.out.println(str2);
}
}
// Java program to demonstrate the
// Character.isValidCodePoint() method
import java.lang.*;
public class gfg {
public static void main(String[] args)
{
// Create 2 int primitives c1, c2 and assign values
int c1 = 0x0128, c2 = 0x123ddd;
boolean bool1 = Character.isValidCodePoint(c1);
boolean bool2 = Character.isValidCodePoint(c2);
String str1 = "c1 is a valid Unicode code point is " + bool1;
String str2 = "c2 is a valid Unicode code point is " + bool2;
// Print bool1, bool2 values
System.out.println(str1);
System.out.println(str2);
}
}
Output:
Reference: https://docs.oracle.com/javase/7/docs/api/java/lang/Character.html#isValidCodePoint(int)
c1 is a valid Unicode code point is true c2 is a valid Unicode code point is false