Is using the Class instance as a Map key a best practice?

Posted by Pangea on Stack Overflow See other posts from Stack Overflow or by Pangea
Published on 2010-04-12T21:21:44Z Indexed on 2010/04/13 7:42 UTC
Read the original article Hit count: 333

Filed under:
|

I have read somewhere that using the class instances as below is not a good idea as they might cause memory leaks. Can someone tell me if if that is a valid statement? Or are they any problems using it this way?

Map<Class<?>,String> classToInstance=new HashMap();

classToInstanceMap.put(String.class,"Test obj");

© Stack Overflow or respective owner

Related posts about java

Related posts about best-practices