### Question:
Util { static int countOccurrence(String s, String pattern) { Matcher matcher = Pattern.compile(pattern).matcher(s); int newLine = 0; while (matcher.find()) { newLine++; } return newLine; } private  Util();   }### Answer:
@Test public void testCountNewLines() { assertEquals(3, countOccurrence("\nHello,\nWorld!\n", NEW_LINE)); assertEquals(2, countOccurrence("Hello, World\n\n", NEW_LINE)); }