Standard Code

Good programming practices

Concise Java code

April 22nd, 2012

Here is an example how concise Java code can be. I wrote 2 methods that do the same, but looks different. It checks if an Iterable object has only one object, which is additionally equals to the one passed as the second argument. Both methods use Objects class added in Java 7. The first method use “&&” operator, which evaluates expression on right only when the left one was true. More…

How to iterate a list with index

April 10th, 2012

There is many ways to iterate a list or other collection in Java. Sometimes it is useful to have also current index, especially when it is a List, where the elements order matters. It can be achieved be several ways. Lets look at the example: More…

StructuredInfo – objects instead of plain String

December 29th, 2011

Common method toString is a simple way to display inner values of an object. But when you get a String want to present it in other format it can be difficult or unsafe to parse it. So better way is to pass a structured object witch can be next serialized to desired format. So I created a project in Scala 2.9.1 for gathering and serializing information in an application. More…