How to use generics to combine duplicate methods with a parameter that has different Java Collections containing the same class type? -


the below 2 methods have exact same code underneath. there way decrease code duplication using java generics here combine them single method?

public static list<string> convert(list<magic> magicstrings); 

note, realmlist<e> extends list<e>.

public static list<string> convert(realmlist<magic> magicstrings); 

if 2 methods have exact same code, there no point in keeping method more specific parameter.

remove convert method takes realmlist. code wants call convert, realmlist or other kind of list, can use convert method takes list.


Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -