it makes me sick ..can you help me with this one? my problem is to identify the whitespaces on my java program and the indices of it but i dont know how to identify the indices(JAVA). heres my code:
import java.util.*;
public class CountSpaces
{
public static void main (String[] args)
{
System.out.print ("Enter a sentence or phrase: ");
Scanner input=new Scanner(System.in);
String str=input.nextLine();
int count = 0;
int limit = str.length();
for(int i = 0; i < limit; ++i)
{
if(Character.isWhitespace(str.charAt(i)))
{
++count;
}
}
thanks ahead.