(1) Static implementations cannot be extended(only static fields and methods can be extended) whereas Singleton implementations can be extended and its methods can be overridden.
(2) Static implementations cannot extend other class's instance fields/methods while Singleton implementations can.
(3) Static implementations must be initialized at the class loading time however Singleton implementations can be lazy initialized or asynchronously initialized.
(4) Static implementations cannot be initialized with a STATE (parameter), whereas Singleton implementations can be.
(5) Static implementations can still have instances (unwanted instances) whereas Singleton implementations prevents it.
May 7, 2008
Difference between Singleton and Static implementations
Apr 5, 2008
Why is String immutable in Java or are they?
Ref: http://www.javaspecialists.eu/archive/Issue014.html
Mar 28, 2008
Some java fun !
What will be the output of this simple program?
pretty simple, isn't it? :)
public class A
{
public void f(Exception e)
{
System.out.println("A");
}
public static void main(String args[])
{
A a = new B();
a.f(new RuntimeException());
}
static class B extends A {
public void f(RuntimeException e)
{
System.out.println("B");
}
}
}
Feb 25, 2008
Implementation of an efficient MRU Cache in Java
LinkedHashMap with doubly linked list to keep the most recently accessed element at the head/tail of the list. Every bucket's list keeps its own elements in the singly linked list and the same elements are doubly linked as well
Difference between Comparable and Comparator
Comparator implementations can be used to define custom sorting even for Objects which already implement Comparable interface in TreeSet, HashSet