When is a static nested class (and static members therein) loaded into memory?
问题 Here, I was trying to implement a singleton class for my Database connectivity using the inner static helper class : package com.myapp.modellayer; public class DatabaseConnection { private DatabaseConnection() { //JDBC code... } private static class ConnectionHelper { // Instantiating the outer class private static final DatabaseConnection INSTANCE = new DatabaseConnection(); } public static DatabaseConnection getInstance() { return ConnectionHelper.INSTANCE; } } However, my doubt is when