November 21, 2005
Weird String code
String String = "String";
String = new String(String);
Pretty confusing if you give this to a java beginner :)
Posted by mvdb at November 21, 2005 06:56 PM
PMD could catch that!
http://pmd.sourceforge.net/rules/strings.html#StringInstantiation
Hi Tom,
Does it also catch the confusing naming ?
:)
Heh, not yet, but that's a good idea for a new rule - don't use identifiers that match a type name!
It's along the same lines as when folks define a class com.mycompany.List and then it's hard to tell if you're using that one or the java.util.List... blah.