A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Java in General
Java 5 Generics
Joined: Jan 04, 2006
Mar 05, 2006 22:34:00
I saw that in Java 5 we can make use of Generics to have declarations like
> s = new
but, Can i also use UserDefined Objects also ? like
Set<EmployeeName> s = new HastSet<EmployeeName>();
Does this Generics information also made part of the Genearated .class file (byteCode) ? or is it only meant for Java Compiler and is lost after compilation?
Java Objects passed by Reference ?? -> you are a failure !!
Joined: Jan 07, 2006
Mar 06, 2006 03:38:00
Yes, you can use user defined objects, as long as they fullfill the requirements of the container poses; e.g.
requires you to implement the equals and hashCode methods or otherwise it won't work quite the way you might think.
The type information is lost when you compile. This is called "type erasure."
subject: Java 5 Generics
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2013