java.lang.Character isValidCodePoint(int codePoint)

Description

The Character.isValidCodePoint(int codePoint) java method determines whether the specified code point is a valid Unicode code point value.

The isValidCodePoint(int codePoint) method of Character class is static thus it should be accessed statically which means the we would be calling this method in this format:

Character.isValidCodePoint(int codePoint)

Non static method is usually called by just declaring method_name(argument) however in this case since the method is static, it should be called by appending the class name as suffix. We will be encountering a compilation problem if we call the java isValidCodePoint() method non statically.

Method Syntax

public static boolean isValidCodePoint(int codePoint)

Method Argument

Data Type Parameter Description
int codepoint the Unicode code point to be tested

Method Returns

The isValidCodePoint(int codePoint) method of Character class returns true if the specified code point value is between MIN_CODE_POINT and MAX_CODE_POINT inclusive; false otherwise.

Compatibility

Requires Java 1.5 and up

Java Character isValidCodePoint(int codePoint) Example

Below is a simple java example on the usage of isValidCodePoint(int codePoint) method of Character class.

package com.javatutorialhq.java.examples;

/*
 * This example source code demonstrates the use of 
 * isValidCodePoint(int codePoint) method of Character class.
 */

public class CharacterIsValidCodePointExample {

	public static void main(String[] args) {
		
		// initialize codepoints
		int codepoint1 = 12;
		int codepoint2 = 5114232;
		
		// check the codepoints are valid
		boolean result1 = Character.isValidCodePoint(codepoint1);
		boolean result2 = Character.isValidCodePoint(codepoint2);
		
		// print the result
		System.out.println("Is codepoint "+codepoint1 +
				" is a valid codepoint?"+result1);
		System.out.println("Is codepoint "+codepoint2 +
				" is a valid codepoint?"+result2);
		
		
		// print the minimum and maximum codepoint
		System.out.println("Minimum codepoint:"+Character.MIN_CODE_POINT);
		System.out.println("Maximum codepoint:"+Character.MAX_CODE_POINT);

	}

}

Sample Output

Below is the sample output when you run the above example.

java Character isValidCodePoint(int codePoint) example output