| Author |
collections and generics
|
sweety singh
Ranch Hand
Joined: Dec 15, 2007
Posts: 49
|
|
what is the differnce between collections and generics.. since their declaration is also same and both are type safe.. please explain me.. thanks...
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16687
|
|
Generics was a feature that was added to Java with version 5. Basically, generic programming allows the developer to use types-to-be-named-later in their code. The collections classes is one of the largest used libraries in core Java that were ported to use it. Henry
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
sweety singh
Ranch Hand
Joined: Dec 15, 2007
Posts: 49
|
|
|
so is collections a type of generics..
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16687
|
|
Originally posted by sweety singh: so is collections a type of generics..
The collection classes are implemented using generics. There are many other classes, which are not collection classes, which are also implemented using generics. The collection classes also use the instanceof operator in its implementation. Does that meant that collections is a type of instanceof? Henry
|
 |
Deepak Bala
Bartender
Joined: Feb 24, 2006
Posts: 6588
|
|
|
Generics can be used without the use of collections. Collections can be used without the use of generics. They are independent of each other. However coupling collections with light generics is a good idea. It prevents runtime bombs where you added something that you did not want to in the collection
|
SCJP 6 articles - SCJP 5/6 mock exams - SCJP Mocks - SCJP 5 Mock exam (Word document ) - SCJP 5 Mock exam in Java.Inquisition format
|
 |
 |
|
|
subject: collections and generics
|
|
|