Character.isWhitespace(): This method is available in java.lang.Character class of Java.
Approach 1: When the argument is of type char.
Syntax:
boolean java.lang.Character.isWhitespace(char ch)
This method takes one argument of type char as its parameter. This method determines if the specified character is white space according to Java.
Parameters: One ch the character to be tested.
Returns: true if the character is a Java white space character; false otherwise.
Exceptions: NA
Java
public class CharacterisWhitespacechar {public static void main(String[] args) {char ch = ' ';System.out.println(Character.isWhitespace(ch));}}
Output:
true
Approach 2: When the argument is of type int.
Syntax:
boolean java.lang.Character.isWhitespace(int codePoint)
This method takes one argument of type int as its parameter. This method determines if the specified character (Unicode code point) is white space according to Java.
Parameters: One parameter is required for this method.
codePoint: the character (Unicode code point) to be tested.
Returns: true if the character is a Java whitespace character; false otherwise.
Exceptions: NA
Java
public class CharacterisWhitespaceint {public static void main(String[] args) {int codePoint = ' ';System.out.println(Character.isWhitespace(codePoint));}}
Output:
No comments:
Post a Comment