• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Collections / Generics Question

 
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's a declaration of the parameter to the parameterized method.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic