Sorting a list in Java: Collections.sort(list, new Comparator<SomeClass>() { @Override public int compare(SomeClass a, SomeClass b) { if (a.getValue() == b.getValue()) { return 0; } else { [...]
Sorting a list in Java: Collections.sort(list, new Comparator<SomeClass>() { @Override public int compare(SomeClass a, SomeClass b) { if (a.getValue() == b.getValue()) { return 0; } else { [...]
Recently I have worked with a code base that has a lot of JDBC boilerplate code. The same code is repeated over and over again and can basically be broken down into the following pattern: ResultSet rs = null; Connection conn = null; PreparedStatement stmt = null; try { conn = [...]
01 Feb, 2013
Posted by: Peter In: Java
At the first glance of String.replaceAll(String regexp, String replacement) it seems very obvious what the method does, and most of the times it does exactly what you want, but under some conditions it does not. Let me show you this by showing you a few unit tests I wrote recently when fixing a bug in [...]
As I wrote in my last post, I recently rewrote one of my hobby projects from ASP.NET MVC to Play! Framework. Play! was very easy to get started with, the only thing required was to have a JDK installed and to download the zip distribution of Play, unzip it to a directory and fire it [...]
So a lot is new since last time I posted. In the end of the summer I moved from Stockholm to San Francisco to start working for a company called Skout, building mobile social networks. With this new job some big changes came:) I am now back to coding Java after several years of mostly [...]
For some time I have been playing around with writing games for Android. The game loads the graphics in form of image sprites, so I needed a way to easily stick several png images into one image. I though there would be tons of free applications available for this purpose, but I didn’t find any, [...]