Skip to content

Instantly share code, notes, and snippets.

@sharmaabhinav
Last active August 29, 2015 14:06
Show Gist options
  • Save sharmaabhinav/dae29b6d9bc56232299e to your computer and use it in GitHub Desktop.
Save sharmaabhinav/dae29b6d9bc56232299e to your computer and use it in GitHub Desktop.
public class Str {
public static void main (String[] args){
String p1 = " abhinav is a good";
int i=0;
int j=0;
int count = 0;
while(i < p1.length()){
if(p1.charAt(i) == '\t' || p1.charAt(i) == ' '){
i++;
}else{
j = i;
count++;
while(j < p1.length() && p1.charAt(j) != ' ' && p1.charAt(j) != '\t'){
j++;
}
i = j;
}
}
System.out.println(count);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment