aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes collections and generics Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "collections and generics" Watch "collections and generics" New topic
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: 18108
    
  39

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: 18108
    
  39

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: 6657
    
    5

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 - More SCJP Mocks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: collections and generics
 
Similar Threads
Generics
generics
generics
Generics
Generics