| Author |
Generics
|
Douglas Kunzman
Greenhorn
Joined: Nov 08, 2007
Posts: 1
|
|
Hi - I am having trouble understanding something about Generics in Schildt book on Java 5.0. On page 31, he states that the types can be the same for a generic like this TwoGen<String, String> x = new TwoGen<String, String>("A", "B"). Then he goes on to state "In this case, both T and V would be of type String. Of course, if the type arguments were always the same, then two parameters would be unnecessary." I don't understand what is quotes. Any geniuses want to elaborate? Doug
|
 |
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18670
|
|
|
He's saying that if, when you design the class, you know that the two generic types will always be equal to each other, then you shouldn't design the class with two generic types - just use one.
|
"I'm not back." - Bill Harding, Twister
|
 |
 |
|
|
subject: Generics
|
|
|