@@ -0,0 +1,961 @@
+package codingbat.warmup2;%0A%0A/*%0A * Given a string, return the count of the number of times that%0A * a substring length 2 appears in the string and also as the%0A * last 2 chars of the string, so %22hixxxhi%22 yields 1%0A * (we won't count the end substring).%0A *%0A * last2(%22hixxhi%22) = 1%0A * last2(%22xaxxaxaxx%22) = 1%0A * last2(%22axxxaaxx%22) = 2%0A */%0A%0Apublic class Last2Test%0A%7B%0A%0A  public static void main(String%5B%5D args)%0A  %7B%0A%0A    Last2Test test = new Last2Test();%0A%0A    System.out.println(%22%3E%22 + test.last2(%22hixxhi%22) + %22%3C%22);%0A    System.out.println(%22%3E%22 + test.last2(%22xaxxaxaxx%22) + %22%3C%22);%0A    System.out.println(%22%3E%22 + test.last2(%22axxxaaxx%22) + %22%3C%22);%0A  %7D%0A%0A  public int last2(String str)%0A  %7B%0A    int count = 0;%0A%0A    if (str.length() %3C 2)%0A      return 0;%0A%0A    String end = str.substring(str.length() - 2);%0A%0A    for (int i = 0; i %3C str.length() - 2; i++)%0A    %7B%0A      String sub = str.substring(i, i + 2);%0A      if (sub.equals(end))%0A      %7B%0A        count++;%0A      %7D%0A    %7D%0A    return count;%0A  %7D%0A%7D

add task last2