Java Static Initialization vs. Instance Initialization – When to use which?

Static Initialization Typically static initialization block is used to initialize static variables of a class. The block is called at the time of class initialization. It is called only once. You can initialize static variables inline. If more complicated logic is required for initialization, a static initialization block can be used. The static initialization blocks … Continue reading Java Static Initialization vs. Instance Initialization – When to use which?

Immutability in Java – What it takes to build an immutable class

Immutability means something that cannot be changed. In java an immutable class is one whose state cannot be changed once it has been created. This post aims to give a guideline on how to make a class immutable. The post contains an example of creating an immutable class.The complete code is available on Github The … Continue reading Immutability in Java – What it takes to build an immutable class

Getting Started with TestNG

TestNG is a testing framework which, inspired by JUnit and NUnit, but introduces things like dependency testing, grouping concept to make testing more powerful and easier to do. It is designed to cover all categories of tests: unit, functional, end-to-end, integration, etc...The NG in TestNG stands for Next Generation. TestNG requires JDK7 or higher.Reference: http://testng.org/doc/index.htmlContinue reading Getting Started with TestNG

An Introduction to Zookeeper – Part I of the Zookeeper series

A distributed system consists of multiple computers that communicate through a computer network and interact with each other to achieve a common goal.Major benefits that distributed systems offer over centralized systems is scalability and redundancy. Systems can be easily expanded by adding more machines as needed, and even if one of the machines is unavailable, … Continue reading An Introduction to Zookeeper – Part I of the Zookeeper series

Multiple Java Installations on OSX and switching between them

Sometimes it may be necessary to have two versions of java on your OSX, and to switch between the two in a fast, reliable and convenient manner. This post aims to show how this can be achieved. I am currently using version 10.9.4 of OSX, and I was required to have both JAVA6 and JAVA7 … Continue reading Multiple Java Installations on OSX and switching between them

Java Inheritance – Super keyword

Inheritance is an important principle in object oriented programming. It is a mechanism in which one object acquires the property of another. The object which gives the properties is called as super/base/parent class and the one that receives the property is called as the sub/derived/child class. The child class inherits all fields and methods of … Continue reading Java Inheritance – Super keyword