lil layzie
Gawd
- Joined
- Jan 7, 2004
- Messages
- 755
I'm trying to count how many white spaces there are in this particular string.
The string is "say some thing"
Which would mean there is 2 white spaces.
I think there is a problem with my aString.charAt
== because it is adding 1 to count for every character, not just a whitespace.
How do i define a white space so i can make an if statement.
The string is "say some thing"
Which would mean there is 2 white spaces.
Code:
int count = 0;
String aString = "say some thing";
for (int n=0; n<aString.length();n++)
{
if (aString.charAt(n)==' ');
{
count++;
}
}
How do i define a white space so i can make an if statement.