Skip to content

Instantly share code, notes, and snippets.

@yenerm
Created April 17, 2020 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yenerm/19ccdb6d14fc40764a13335167cd6081 to your computer and use it in GitHub Desktop.
Save yenerm/19ccdb6d14fc40764a13335167cd6081 to your computer and use it in GitHub Desktop.
Naive singleton implementation
<!-- Copyright 2019 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
public class Singleton{
private static Singleton INSTANCE;
private Singleton(){}
public static Singleton getInstance(){
if (INSTANCE == null){
INSTANCE = new Singleton();
}
return INSTANCE;
}
private int count = 0;
public int count(){ return count++; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment