Java Data Type How to - is White space








Question

We would like to know how to is White space.

Answer

isWhitespace():true if the argument is whitespace.

which is any one of the following characters:

space (' '), tab ('\t'), newline ('\n'), carriage return ('\r'),form feed ('\f')

public class MainClass {
  public static void main(String[] args) {
    char symbol = 'A';
//from w w w  .  j av a  2s.  c o  m
    if (Character.isWhitespace(symbol)) {
      System.out.println("true");
    }else{
      System.out.println("false");
    }
  }
}

The code above generates the following result.