aspose file tools
The moose likes Java in General and the fly likes Generics Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Generics" Watch "Generics" New topic
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
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Generics
 
Similar Threads
Generics
Generics
Generics..
Generics
Generics