Prev Next

Java / Generics

How do you create a generic method which accepts generic types and return a generic type?

Replace all the raw type with the generic types like E,K, V etc and also add the list of generic types before the return type using <>.

public <K,V> V StoreThePair(K key, V value) {
                              return V;
}

More Related questions...

Show more question and Answers...


Comments & Discussions