Live to learn

This is an old ar­ti­cle from 2012. I was a kid. I learned a lot since then, so please do think twice when tak­ing ad­vice from me as a kid.

Just spent a whole hour on a stupid prob­lem:

//... (Storeable is an interface)

HashMap<String, Class<? extends Storeable>> types = new HashMap<String, Class<? extends Storeable>>();

//... (object is an instance of a class that implements Storeable)

types.add(object.getTag(), object.getClass());

//...

Thought it was a prob­lem with the Gener­ics, but the Gener­ics are fine. Here is the so­lu­tion:

types.put(object.getTag(), object.getClass());

… *facepalm*

This post was im­port­ed from tum­blr

Tumblr

Archived blog posts from squareys.tum­blr.com.