StringUtils { public static <T> String enumerate(List<T> items) { StringBuilder enumeration = new StringBuilder(); int size = items.size(); for (int i = 0; i < size; i++) { if (i > 0) { if (size > 2) { enumeration.append(", "); } else { enumeration.append(" "); } if (i == size - 1) { enumeration.append("and "); } } enumeration.append(items.get(i).toString()); } return enumeration.toString(); }  static String removePrefix(String string, String separator); static String removePrefixCaseInsensitive(String string, String separator); static String removePostfix(String string, String separator); static String removePostfixCaseInsensitive(String string, String separator); static String removePostfixAndPrefix(String input, String prefixSeparator,
      String postfixSeparator); static String removePostfixAndPrefixCaseInsensitive(String input, String prefixSeparator,
      String postfixSeparator); static String enumerate(List<T> items);  }
@Test public void test1Item() { assertEquals("item1", StringUtils.enumerate(Arrays.asList("item1"))); }
@Test public void test2Items() { assertEquals("item1 and item2", StringUtils.enumerate(Arrays.asList("item1", "item2"))); }
@Test public void test3Items() { assertEquals("item1, item2, and item3", StringUtils.enumerate(Arrays.asList("item1", "item2", "item3"))); }