Now let's write a user input example. Update the existing IsWhiteSpace.java
file with the following code:
import java.util.Scanner;
public class IsWhiteSpace {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter a Unicode character: ");
int input = scanner.next().charAt(0);
boolean isWhitespace = Character.isWhitespace(input);
System.out.println(input + " is a Java whitespace character?: " + isWhitespace);
}
}
The above code takes user input, checks whether the input is a Java whitespace character, and prints the result accordingly.