logo

Java IsWhitespace() Method


Show

The method decides whether the particular char charge is a white space, which incorporates space, tab, or innovative lineup. isWhitespace() is an integral method in a java that resolves if the specified character (Unicode code point) is white space according to Java. ... It is a Unicode space character (SPACE_SEPARATOR, LINE_SEPARATOR, or PARAGRAPH_SEPARATOR) but is not also a non-breaking space ('\u00A0', '\u2007', '\u202F').

Syntax

boolean isWhitespace(char ch)

Parameters

Here is the detail of parameters −

  • ch − Primitive character type.

Return Value

  • This method returns true if the passed character is really a white space.

Example

public class Test {

   public static void main(String args[]) {
      System.out.println(Character.isWhitespace('c'));
      System.out.println(Character.isWhitespace(' '));
      System.out.println(Character.isWhitespace('\n'));
      System.out.println(Character.isWhitespace('\t'));
   }
}

Output

false
true
true
true

Here at Intellinuts, we have created a complete Java tutorial for Beginners to get started in Java.