Character.isSpaceChar() method in Java
The java.lang.Character.isSpaceChar(char ch) is an inbuilt method in java which determines if the specified character is a Unicode space character. A character is considered to be a space character if and only if it is specified to be a space character by the Unicode Standard.
This method returns true if the character’s general category type is any of the following ?
- SPACE_SEPARATOR
- LINE_SEPARATOR
- PARAGRAPH_SEPARATOR
Syntax:
public static boolean isSpaceChar(char ch)
Parameter: The function accepts one mandatory parameter ch which specifies the character to be tested.
Return Value: This method returns a boolean value. The value is True if the character is a space character, False otherwise.
Below programs illustrate the Character.isSpaceChar() method:
Program 1:
// Java program to illustrate the // Character.isSpaceChar() method import java.lang.*; public class gfg { public static void main(String[] args) { // create 2 char primitives c1, c2 and assign values char c1 = '$', c2 = '\u2025'; // Function to check if the character is a unicode space or not boolean bool1 = Character.isSpaceChar(c1); System.out.println("c1 is a space character? " + bool1); // Function to check if the character is a unicode space or not boolean bool2 = Character.isSpaceChar(c2); System.out.println("c2 is a space character? " + bool2); } } |
c1 is a space character? false c2 is a space character? false
Program 2:
// Java program to illustrate the // Character.isSpaceChar() method import java.lang.*; public class gfg { public static void main(String[] args) { // create 2 char primitives // c1, c2 and assign values char c1 = '*', c2 = '\u2028'; // Function to check if the character is a unicode space or not boolean bool1 = Character.isSpaceChar(c1); System.out.println("c1 is a space character? " + bool1); // Function to check if the character is a unicode space or not boolean bool2 = Character.isSpaceChar(c2); System.out.println("c2 is a space character? " + bool2); } } |
c1 is a space character? false c2 is a space character? true
Reference: https://docs.oracle.com/javase/7/docs/api/java/lang/Character.html#isSpaceChar(char)
Recommended Posts:
- Java.lang.Short toString() method in Java with Examples
- Java.util.Collections.disjoint() Method in java with Examples
- Java lang.Long.numberOfTrailingZeros() method in Java with Examples
- Java lang.Long.lowestOneBit() method in Java with Examples
- Java lang.Long.numberOfLeadingZeros() method in Java with Examples
- Java lang.Long.byteValue() method in Java with Examples
- Java.util.Collections.rotate() Method in Java with Examples
- Java lang.Long.builtcount() method in Java with Examples
- Java lang.Long.reverse() method in Java with Examples
- Java lang.Long.highestOneBit() method in Java with Examples
- Java.lang.string.replace() method in Java
- Java Clock withZone() method in Java with Examples
- Java Clock tickMinutes() method in Java with Examples
- Java.util.ArrayList.addall() method in Java
- Java 8 | ArrayDeque removeIf() method in Java with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

