java.lang.Character isWhitespace(int codePoint)
Description
- 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.
The isWhitespace(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.isWhitespace(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 isWhitespace() method non statically.
Method Syntax
public static boolean isWhitespace(int codePoint)
Method Argument
Data Type | Parameter | Description |
---|---|---|
int | codepoint | the character (Unicode code point) to be tested. |
Method Returns
The isWhitespace(int codePoint) method of Character class returns true if the character is a Java whitespace character; false otherwise.
Compatibility
Requires Java 1.5 and up
Java Character isWhitespace(int codePoint) Example
Below is a simple java example on the usage of isWhitespace(int codePoint) method of Character class.
package com.javatutorialhq.java.examples; /* * This example source code demonstrates the use of * isWhitespace(int codePoint) method of Character class. */ public class CharacterIsWhitespaceCodepointExample { public static void main(String[] args) { // initialize a codepoint int codepoint = 49; // check if the codepoint is a whitespace or not boolean checkBool = Character.isWhitespace(codepoint); // print result if(checkBool){ System.out.print("Codepoint '"+codepoint+"' is a whitespace"); } else{ System.out.print("Codepoint '"+codepoint+"' is not a whitespace"); } } }
Sample Output
Below is the sample output when you run the above example.