java tutorial - Java - Method Character.isWhitespace() - java programming - learn java - java basics - java for beginners



Java characters iswhitespace

Learn Java - Java tutorial - Java characters iswhitespace - Java examples - Java programs

Description

Java - Method Character.isWhitespace() — specifies in Java whether the specified char value is an empty space that includes a space, tab, or new string.

Syntax

boolean isWhitespace(char ch)
click below button to copy the code. By - java tutorial - team

Options

Detailed information about the parameters:

  • ch is a primitive character type (char).

Return value

  • In Java, Character.isWhitespace () returns true if the passed character is an empty space.

Sample Code

public class Test{
    public static void main(String args[]){
      System.out.println("Value \" \" (space) the empty space? Answer: " + Character.isWhitespace(' '));
      System.out.println("Value \"\\n\" (new line) empty space? Answer: " + Character.isWhitespace('\n'));
      System.out.println("Value \"\\t\" (tabulation) empty space? Answer: " + Character.isWhitespace('\t'));
      System.out.println("Value \"1\" empty space? Answer: " + Character.isWhitespace('1'));
      System.out.println("Value \"p\" empty space? Answer: " + Character.isWhitespace('p'));
      System.out.println("Value \"&\" empty space? Answer: " + Character.isWhitespace('&'));
   }
}
click below button to copy the code. By - java tutorial - team

Output

Value "\"\ (space) is an empty space? Answer: true
Value "\n" (new line) empty space? Answer: true
value "\t" (tabulation) empty space? Answer: true
value "1" empty space? Answer: false
value of "p" is empty space? Answer: false
Value "&" empty space? Answer: false

Related Searches to Java - Method Character.isWhitespace()