We have already know that ArrayList ..
ArrayList class is provide resizeable-array and implements all the List interface.
ArrayList also permit all elements and also contain null.
Like integer, string, or null and whatever..
for ex.
ArrayList<integer> al = new ArrayList();
here, <integer> is list type which type of array is contain so that ....
and after you have add list value into arraylist
al.add(1);
al.add(2);
al.add(3);
ArrayList is one Method to use shuffle your arraylist..
Collection.Shuffle();
it use randomly arrange values.Example :
public class demo{public static void main(String args[]){
ArrayList<integer> al = new ArrayList();
al.add(1);
al.add(2);
al.add(3);
System.out.println("print arraylist :- "+al);
Collection.shuffle(al);
System.out.println("print arraylist after shuffle :-"+al);
}
}
Comments
Post a Comment