package test;
import java.util.HashMap;
class Check {
private static Check check = new Check();
private static HashMap<String,String> map = new HashMap<String, String>();
static{
System.out.println("***********In static block***********");
Check.map.put("1", "One");
Check.map.put("2","Two");
}
private Check(){
System.out.println("Map Contains "+map.get("1"));
}
public static Check getCheck() {
return Check.check;
}
}
public class CheckStatic{
public static void main(String[] args) {
Check.getCheck();
}
}
I have created Singleton class which has static block. And in static block I have initialized hashmap and trying to access that in constructor of Singletion class.But I am getting exceptionInInitializerError. Please suggest what is am trying which is wrong...