The Daily WTF
Combining Java with lower-level bit manipulations is asking for trouble- not because the language is inadequate to the task, but because so many of the developers who work in Java are so used to working at a high level they might not quite “get” what they need to do.
Victor inherited one such project, which used bitmasks and bitwise operations a great deal, based on the network protocol it implemented. Here’s how the developers responsible created their bitmasks:
private static long FFFFFFFF = Long.parseLong(“FFFFFFFF”, 16);
So, the first thing that’s important to note, is that Java does support hex literals, so 0xFFFFFFFF is a perfectly valid literal. So we don’t need to create a string and parse it. But we also don’t need to make a constant simply named FFFFFFFF, which is just the old twenty = 20 constant pattern: technically you’ve made a constant but you haven’t actually
To read the full article click on the 'post' link at the top.