3 ms·
Ok, in that regard I think your post was very informative. Raising awareness of this language detail is very important, because it can lead to bugs which are ve
by mkaufmann 15y ago
Ok, in that regard I think your post was very informative. Raising awareness of this language detail is very important, because it can lead to bugs which are very hard to detect.
The two most valuable advices from your post is directly the first line (but I have to admit that I overread it the first time I looked at the post). And second to use some tooling like the Eclipse code checker or findbugs (which was mentioned in another comment) to make implicit conversions visible to the programmer.
The only point I still disagree, though this is only a minor point, is that even with your explanation the possible solution of creating seperate instances is really no help. My point beeing that either you know that autoboxing occurs at a point and one can handle it correctly, or one doesn't know and in that case you also can't create seperate integer instances. This is from the point of view of someone who worked most of his career with Java and that line just makes my eyes bleed. But I can also understand if this looks like nitpicking to others ;)