Java 8 default and static methods example

In this tutorial I am going to show how default and static methods can be included into Java 8 interface. Prior to Java 8 we did not have such mechanism to include default method or static method into interface but Java 8 provides such option to include those methods. Static methods are regarded as utility methods, not as essential, core methods. Whereas default methods are treated as common behaviors for all the client classes.

Continue

How singleton pattern works in Java

Introduction Here in this post we will discuss how singleton pattern works in Java. Singleton pattern is a design solution, where an application wants to have one and only one instance of a class, in all possible scenarios without any exceptional condition. The singleton instance is actually created per JVM but not across multiple JMVs. The singleton class has a private constructor that prevents creation of instance from outside the class, i.e., the class itself controls the creation of the object. The singleton class defines a public static operation that…

Continue