Signup/Sign In

Java Character isWhitepsace(int codePoint) Method

Java isWhiteSpace(int codePoint) method is a part of Character class. This method is used to check whether the specified Unicode codepoint character is whitespace in accordance with Java.

This method also supports supplementary characters. A character is a Java whitespace character if and only if it satisfies one of the following criteria:

  • It is a Unicode space character (SPACE_SEPARATOR, LINE_SEPARATOR, or PARAGRAPH_SEPARATOR) but is not also a non-breaking space ('\u00A0', '\u2007', '\u202F').
  • It is '\t', U+0009 HORIZONTAL TABULATION.
  • It is '\n', U+000A LINE FEED.
  • It is '\u000B', U+000B VERTICAL TABULATION.
  • It is '\f', U+000C FORM FEED.
  • It is '\r', U+000D CARRIAGE RETURN.
  • It is '\u001C', U+001C FILE SEPARATOR.
  • It is '\u001D', U+001D GROUP SEPARATOR.
  • It is '\u001E', U+001E RECORD SEPARATOR.
  • It is '\u001F', U+001F UNIT SEPARATOR.


public static boolean isWhitespace(int codePoint)


The parameter passed is the Unicode codepoint character to be checked whether it is a Java whitespace character.


Returns the boolean value true if the specified codepoint character is a Java whitespace character else return false.

Example 1:

Here, the characters are checked whether they are Java whitespace characters or not.

public class StudyTonight
	public static void main(String[] args)
		int cp1 = 10;  
		int cp2 = 60;  
		int cp3 = 119;  
		int cp4 = 11;   
		int cp5 = 1232;  

		boolean b1 = Character.isWhitespace(cp1);  
		boolean b2 = Character.isWhitespace(cp2);  
		boolean b3 = Character.isWhitespace(cp3);  
		boolean b4 = Character.isWhitespace(cp4);  
		boolean b5 = Character.isWhitespace(cp5);  

		System.out.println((char)cp1 +" is a Java Whitespace??::  "+b1);  
		System.out.println((char)cp2 +" is a Java Whitespace??::  "+b2);  
		System.out.println((char)cp3 +" is a Java Whitespace??::  "+b3);  
		System.out.println((char)cp4 +" is a Java Whitespace??::  "+b4);  
		System.out.println((char)cp5 +" is a Java Whitespace??::  "+b5);  

is a Java Whitespace??:: true
< is a Java Whitespace??:: false
w is a Java Whitespace??:: false
is a Java Whitespace??:: true
? is a Java Whitespace??:: false

Example 2:

Here is a user-defined example where anyone using this code can put a value of his choice and get the equivalent output.

import java.util.Scanner; 
public class StudyTonight
	public static void main(String[] args)
			System.out.print("Enter the Unicode character: ");  
			Scanner sc = new Scanner(;        
			int cp = sc.nextInt(); 
			boolean b = Character.isWhitespace(cp);
			System.out.println((char)cp + " is a Java Whitespace??: "+b);
		catch(Exception e)
			System.out.println("Invalid Input!!");

Enter the Unicode character: 12
is a Java Whitespace??: true
Enter the Unicode character: 76
L is a Java Whitespace??: false

Live Example:

Here, you can test the live code example. You can execute the example for different values, even can edit and write your examples to test the Java code.

About the author:
A Computer Science and Engineering Graduate(2016-2020) from JSSATE Noida. JAVA is Love. Sincerely Followed Sachin Tendulkar as a child, M S Dhoni as a teenager, and Virat Kohli as an adult.