• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Generics

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic