ArrayList

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 ??

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. )

Afraid that is not correct. A List cannot hold primitives, but you can add what appears to be a primitive by auto-boxing.The real difference is that you will most probably have to cast the elements from the second List (without the <>) and casting is error-prone.

a. In the first initialization i know that the ArrayList is a String type, but what about the type of second ArrayList ??

Even if you declared the first list as ArrayList<String>, it actually holds Objects and not necessarily Strings. The difference between the two declarations is that in the first one, the compiler is aware that the list should contain Strings.
For example, run this and check out the output: