Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2014
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. public static <E> ArrayList<Collection<E>> SplitCollection (Collection<E> col) throws InstantiationException, IllegalAccessException {
  2. ArrayList<Collection<E>> listOfCollections = new ArrayList<>();
  3. for(E el: col) {
  4. // creating an empty collection of type E
  5. Collection<E> colEl = col.getClass().newInstance();
  6. colEl.add(el);
  7. listOfCollections.add(colEl);
  8. }
  9. return listOfCollections;
  10. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement