• Post Reply Bookmark Topic Watch Topic
  • New Topic

Collections / Generics Question  RSS feed

 
Rick Portugal
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm reading about Collections at http://java.sun.com/docs/books/tutorial/collections/interfaces/set.html

I like the tutorial because it is updated for J2SE 5, including generics.

But I don't understand this syntax:The tutorial says this is a generic method that returns a Set of the same generic type as the one passed in. I don't understand what the first <E> in the method signature means. (public static <E>)

I would have thought the syntax would be:Without the first <E>. That, in my mind, would be a static method called removeDups that takes a Collection of type E, and returns a Set of type E.

What does "public static <E> Set<E> removeDups(Collection<E> c)" mean?
 
Tony Morris
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a declaration of the parameter to the parameterized method.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!