• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Method Syntax

 
Steven Zaluk
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have seen code like below a couple of times now but I am not sure exactly what the <X> X part means. Can anybody explain this to me?

Thanks,
Steve

 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you only had "public X get(String key);" the compiler would think that X is a real class. However, in your case, X is not a real class, but a generic class. You use <X> to tell the compiler that X is a generic class.
 
Rob Spoor
Sheriff
Pie
Posts: 20610
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Generic methods and constructors
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic