Yogesh,
You are getting the compiler error because you aren't using generics. An ArrayList without <> is actually a raw ArrayList, not a generic array list.
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 !
Today you are you, that is turer than true. There is no one alive who is youer than you! - Seuss. Tiny ad:
a bit of art, as a gift, that will fit in a stocking