### Question:
StringUtils { public static int countMatches(String str, String sub) { if (str == null || str.length() == 0 || sub == null || sub.length() == 0) { return 0; } int count = 0; int idx = 0; while ((idx = str.indexOf(sub, idx)) != -1) { count++; idx += sub.length(); } return count; } private  StringUtils(); static String toString(Object source); static String null2Empty(Object source); static String encodeToCN(String isoString); static String encodeToEN(String cnString); static String encode(String srcString, String fromEncode,
                              String toEncode); static String formater(String sourceString, Object[] args); static boolean isNumeric(String value); static String String2Hex(String str); static String Hex2String(String bytes); static Long[] stringArray2LongArray(String[] sArray); static Integer[] stringArray2IntegerArray(String[] sArray); static String wrapQuota(String str); static String compressHtml(String html); static int countMatches(String str, String sub); static String formatSize(long size); static Object convertValueByType(String type, String value); static String reverse(String s); static String number2Chinese(String n); static String multiDigit2ChineseMoney(String n); static String multiDigit2Chinese(String n); static String siginDigit2Chinese(Object n); static String getContentFromClassResource(String path, Map<String, Object> args); static String fromEncode; static String toEncode; static boolean encodeToCN; static HtmlCompressor compressor; }### Answer:
@Test public void countMatches() { Assert.assertEquals(1, StringUtils.countMatches("?", "?")); Assert.assertEquals(1, StringUtils.countMatches("c.a=?", "?")); Assert.assertEquals(2, StringUtils.countMatches("?,?", "?")); Assert.assertEquals(2, StringUtils.countMatches("c.a in (?,?)", "?")); Assert.assertEquals(2, StringUtils.countMatches("c.a>=? or c.bb >=?", "?")); }