Your generic ArrayList declaration should be as follows to allow different data types.
Please observe the above generic ArrayList declaration. There is Object as a data type. So you can add any type of object to ArrayList.
If you want to add specific type of objects, you need to specify that type in the ArrayList declaration. Empty sharp brackets at left hand side are not allowed.
Hope this helps !
Those cherries would go best on cherry cheesecake. Don't put those cherries on this tiny ad: