Last active
August 29, 2015 14:06
-
-
Save sharmaabhinav/dae29b6d9bc56232299e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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