How the genric array list working ??

Sathish David  Kumar N
Sathish David  Kumar N used Ask the Experts™

How the genric array list working ?? what is the differeneces b/w normal arraylist and genric array list
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2009
Regular arrayList -

List test = new ArrayList();

When you do get on the the arraylist test, you will have to cast.

On the other hand in a generic arraylist you would specify the type of the object when you declare the arraylist -

ArrayList<MyClass> a = new ArrayList<MyClass>();
In addition to what a_b wrote, using a generic list (or set, or any other type of collection) prevents mistakes (such as put the wrong type of object in the list) and saves you from having to cast everything you get from the list.
I strongly recommend reading Gilad Bracha's document introducing generics at
It starts with the basic stuff, so you don't have to read all of it to get the hang of it, but chapters 1-3 are a great introduction to what you can do and why using generics is (usually) better.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial