public class CustomContracts { public void testSubstring(String s) { if (s.substring(-1).length() == 0) { System.out.println("Oops"); } } public void testSubstring2(String s, int index) { if (s.substring(0, index).length() == 0 || index < 0) { System.out.println("Oops"); } } public void testSubstring3(String s, int index) { if (s.substring(3, index).equals("foo") || index == 1) { System.out.println("Oops"); } } public void testCharAt(String s) { int index = 0; while (Character.isDigit(s.charAt(index))) { index++; } if (index == 0 || index == s.length()) { System.out.println("Wrong"); } } }