Java Tutorial

Java Control Statements

Object Oriented Programming

Java Built-in Classes

Java File Handling

Java Error & Exceptions

Java Multithreading

Java Synchronization

Java Networking

Java Collections

Java List Interface

Java Queue Interface

Java Map Interface

Java Set Interface

Java Data Structures

Java Collections Algorithms

Java Miscellaneous

Advanced Java

Java APIs & Frameworks

Java Useful Resources

Java - isWhitespace() Method



Description

The method determines whether the specified char value is a white space, which includes space, tab, or new line.

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'));
   }
}

This will produce the following result −

Output

false
true
true
true
java_characters.htm
Advertisements