Created
May 28, 2019 14:37
-
-
Save cgrand/7e4efd65d3954092e31e329b0a70e35d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package doubetrouble; | |
import java.util.concurrent.Callable; | |
public class Main implements Callable<Object> { | |
private static class Constants { | |
final static Object constant; | |
static { | |
System.err.println("Lazy cosntants init"); | |
constant = new Object(); | |
} | |
} | |
static { | |
System.err.println("Main init"); | |
} | |
public static void main(String[] args) { | |
try { | |
new Main().call(); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
} | |
public Object call() throws Exception { | |
System.err.println("Main call"); | |
return Constants.constant; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment