Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public int wordCount(String s1)
- {
- String check = new String();
- int counter = 0;
- String one = this.str.toLowerCase();
- String two = s1.toLowerCase();
- for (int i = 0; i <one.length() - (two.length() +1); i++)
- {
- check = one.substring(i,(i+two.length()));
- if(check.equals(two))
- {
- if ((one.charAt(two.length() +1) == ' ' || one.charAt(two.length() +1) == '.') && (one.charAt(i-1) == ' ' || i == 0))
- {
- counter++;
- }
- }
- }
- return counter;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement