The Java collections framework includes the concept of NavigableSets / NavigableMaps. The principle behind these interfaces is that taking a SortedSet/SortedMap you can use a subset of it. Some examples: Given the following set: 1 2 3 4 5 @Before … Continue reading →
Some times it is useful to throw “random” data at your algorithm to see if it produces the correct result (see fuzz testing). This is especially true if you are writing some fundamental piece of code like a sort algorithm, … Continue reading →
Microbenchmarking is the practice of measuring the performance characteristics (like CPU, memory or I/O) of a small piece of code to determine which would be better suited for a particular scenario. If I could offer but one advice on this, … Continue reading →
Problem statement: you have some value objects for which you implemented toString() (for debugging purposes) and now you would like to test using a unit test that these implementations exist. Possible solutions: – Use reflection to detect the existence of … Continue reading →
Before starting to post more code, I would like to to take a minute and show how the actual sample code can be accessed easily. Of course you can always browse it using a web browser, but there are better … Continue reading →
The long awaited java 7 developer preview release (build 130) can now be downloaded here. The final release is scheduled for July. For sending feedback you can use the forums and the bug-reporting channel. For more details, make sure you … Continue reading →
I’ve seen many times code like the one below: 1 if (collection.size() > 0) { … }if (collection.size() > 0) { … } There is just something which inherently “clicks” with most programmers minds when they think “non-empty”. There is … Continue reading →