shivang sarawagi wrote:There are two initializations of ArrayLists
My questions are a. In the first initialization i know that the ArrayList is a String type, but what about the type of second ArrayList ??
b. Can an ArrayList hold elements of different primitive types ??
a. you are pertaining of the second arraylist as arraylist of the second line? then ArrayList is also equal to ArrayList<Object>
b. ArrayList without generics can hold primitive types but autoboxing will occur first. (Eg. int primitive will be automatically be converted to Integer, since Integer extends Number extends Object, it is possible. )