java singleton
public class DB { // champs de l'objet private DB(){ // initialisation des champs } private static final DB INSTANCE = new DB(); public static DB getInstance(){ return INSTANCE; } }
java singleton
public final class SomeSingleton { public static final SomeSingleton INSTANCE; private SomeSingleton() { INSTANCE = (SomeSingleton)this; System.out.println("init complete"); } static { new SomeSingleton(); } }