Category Archives: standard edition

Simple features of Java Standard Edition (J2SE).

[Java] Unit tests – JUnit vs TestNG

Unit testing is a very important thing in applications. By testing your class you can prove that your code is free of most bugs and complies with the specification (you can’t remove all bugs, but can make your code harder … Continue reading

Leave a comment

[Java] The fastest singleton

Everybody know how to write thread-safe singleton. Consider standard approach: The example above could be slow – consider synchronization cost every time you getting singleton instance. Can you do it faster? Of course: The synchronization cost is much lower – … Continue reading

5 Comments

[Java] Generic classes

The problem: you have to create class which keep object of unidentified class (for example while designing part of library) inside it – and want to use this object later. The first attempt is to create class which keeps Object … Continue reading

Leave a comment

[Java] Accessing private fields

The problem: you have to use class that we can’t modify for some reason. You want to get or set values of fields (name, surname) of class User, but cannot do it in the other way that calling toString() method … Continue reading

Leave a comment