What is a static <E>?

I just read a java build tutorial and wonder why is it <E> needed after statics?

public static <E> Set <E> removeDups (Collection <E> c) {
    return new LinkedHashSet (c);
}


Thanks Sarah

+5
source share
2 answers

. static , .. , . <E> , E, / . , Set<E>, , Set of E, Collection<E> , E.

E , , . . ,

   Collection<String> myStrings = new ArrayList<String>();
   .. add strings
   Set<String> uniqueStrings = SomeClass.removeDups(myStrings);

,

   Set<Integer> uniqueStrings = SomeClass.removeDups(myStrings);

, .

+8

<E> - , , Generics Java 5.0

. .

+2

All Articles