Does any one know a very simple method to do that. Ex:
List<String[]> myList=new ArrayList<String[]>();
myList.add(s1);
myList.add(s2);
List<String[]> newList=new ArrayList<String[]>();
newList.add(n1);
newList.add(n2);
myList.addAll(newList);
will print out:
s1 s2 n1 n2
Can we make a method like addAllToTop
so that
myList.addAllToTop(newList);
will print out:
n1 n2 s1 s2
Just use the overload of addAll
which takes the index at which to insert the items:
myList.addAll(0, newList);
No need for a new method at all.
See more on this question at Stackoverflow