Recursive class instance initialization for singleton object

0 votes
asked Jan 12 by user3558915

Does the problem with

public class Elvis {         
public static final Elvis ELVIS = new Elvis();         
private static final Boolean LIVING = true;         
private static final Boolean alive = LIVING;  

public final Boolean lives() 
{
return alive;
}           
public static void main(String[] args)         
{                 
System.out.println("Hello"+ELVIS.lives());         
} 
}

has been solved in java 8.

As In Java 7 and previous version has the problem of not initializing the instance variable if it has been declared after the recursive initialization of self class object.

Please log in or register to answer this question.

...