1

Method 1

 public static synchronized Database getInstance(){
   if(INSTANCE == null){
     INSTANCE = new Database();
   }
   return INSTANCE;
}

Method 2

private static final Database INSTANCE = new Database();
    public static Database getInstance(){
        return INSTANCE;
    }

Which is the better choice ?

Raptor
  • 53,206
  • 45
  • 230
  • 366

0 Answers0