| Author |
Generics refresher
|
Hussein Baghdadi
clojure forum advocate
Bartender
Joined: Nov 08, 2003
Posts: 3359
|
|
Hi,
In Java Generics, type conversion is based on the base type, not the parameters to that type.
Why this code is failing?
Conversion is based on List and LinkedList, not on Integer and Number.
Thanks.
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16695
|
|
Think about what would happen if the compiler allowed the assignment.
If the assignment was allowed....
Then didn't I just put a double object into the ints list?
Henry
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
Hussein Baghdadi
clojure forum advocate
Bartender
Joined: Nov 08, 2003
Posts: 3359
|
|
|
So when Generics are involved, type conversion is based on the parameterized type (List, LinkedList) or on the parameter to the type (Integer, Number)?
|
 |
 |
|
|
subject: Generics refresher
|
|
|