### Question:
CollectionUtils { public static int getLastIndex(final Collection<?> collection) { if (isEmpty(collection)) { return 0; } return collection.size() - 1; } private  CollectionUtils(); static String toString(final Collection<?> collection); static int getLastIndex(final Collection<?> collection); static boolean isEmpty(final Collection<?> collection);  }### Answer:
@Test public void testGetLastIndex() { Assert.assertEquals(0, CollectionUtils.getLastIndex(null)); List<String> list = new ArrayList<String>(); Assert.assertEquals(0, CollectionUtils.getLastIndex(list)); list.add("1"); Assert.assertEquals(0, CollectionUtils.getLastIndex(list)); list.add("2"); Assert.assertEquals(1, CollectionUtils.getLastIndex(list)); list.add("4"); Assert.assertEquals(2, CollectionUtils.getLastIndex(list)); }