• Post Reply Bookmark Topic Watch Topic
  • New Topic

Generics  RSS feed

 
Douglas Kunzman
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!