Advertisement
oona

countAbc

Sep 26th, 2014
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.24 KB | None | 0 0
  1. public int countAbc(String str) {
  2.  
  3.    if (str.length()<3)   return 0;
  4.  
  5.   if (str.substring(0, 3).equals("abc") || str.substring(0,3).equals("aba"))
  6.  
  7.   return 1 + countAbc(str.substring(1));
  8.   else
  9.   return countAbc(str.substring(1));
  10. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement