Check if a character is a white space in Java
Description
The following code shows how to check if a character is a white space.
Example
/*www.j av a2s . c o m*/
public class Main {
public static void main(String[] args) {
char a[] = { 'a', 'b', '5', '?', 'A', ' ' };
for (int i = 0; i < a.length; i++) {
if (Character.isWhitespace(a[i])){
System.out.println(a[i] + "is a White Space ");
}
}
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »