File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes what is main advantage of generics in 1.5 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "what is main advantage of generics in 1.5" Watch "what is main advantage of generics in 1.5" New topic
Author

what is main advantage of generics in 1.5

vinod sai
Greenhorn

Joined: Jul 30, 2009
Posts: 2
Hi
Please tell me generics advantage in java 1.5.
Sebastian Janisch
Ranch Hand

Joined: Feb 23, 2009
Posts: 1183
It comes down to type safety.

Prior to Java 5 and generics, you could place any type of Object in a List, Map, etc.

This resulted in a lot of casting and error prone code.

Generics lets you tell the Map that only objects of type MyFancyObject go into the Map, nothing else, end of story.


JDBCSupport - An easy to use, light-weight JDBC framework -
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19684
    
  20

Moving to Beginning Java.

And read this.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Muhammad Khojaye
Ranch Hand

Joined: Apr 12, 2009
Posts: 449

Generics Tutorial


http://muhammadkhojaye.blogspot.com/
 
wood burning stoves
 
subject: what is main advantage of generics in 1.5