ListHelper { static String serializeList(List<String> list, char separatorChar) { StringBuilder sb = new StringBuilder(); for (String element : list) { if (sb.length() > 0) { sb.append(separatorChar); } sb.append(element); } return sb.toString(); }  static List<String> parseString(String serializedString, char separatorChar);  }
@Test public void testSerializeList() { assertEquals("", ListHelper.serializeList(Arrays.<String> asList(), '|')); assertEquals("", ListHelper.serializeList(Arrays.asList(""), '|')); assertEquals("a", ListHelper.serializeList(Arrays.asList("a"), '|')); assertEquals("a|b", ListHelper.serializeList(Arrays.asList("a", "b"), '|')); }