Collections can be of a particular type i.e they are only allowed to hold objects of a defined type. This is called “bounded by”. For example: Java Code: ArrayList arrayList = new ArrayList(); Vector vector = new Vector(); We declared an ArrayList and a Vector both bounded by String. We cannot store objects other than String in these. Lets try to store an integer in Vector and see what happens. Java Code: Vector vector = new Vector(); ...
ArrayList arrayList = new ArrayList(); Vector vector = new Vector();
Vector vector = new Vector();
Collections have very useful methods. Let us see how to rotate objects in a given list. The method "rotate" has two inputs, a list and a distance parameter which defines rotation distance. The distance can be positive, negative or zero. Objects in the list will be rotated by the specified parameter. Let us take an example to rotate objects of Car class. For example, suppose list comprises [t, a, n, k, s]. After invoking Collections.rotate(list, 1) ...
thanks...
sorry for all the questions
thanks...
06-14-2013, 02:22 PM in gbonecapone