Skip to content

Instantly share code, notes, and snippets.

@scottferg
Created January 20, 2010 18:17
Show Gist options
  • Save scottferg/282070 to your computer and use it in GitHub Desktop.
Save scottferg/282070 to your computer and use it in GitHub Desktop.
package com.myapp.mobile;
public class Singleton
{
private static Singleton instance = null;
protected Singleton()
{
// Exists only to defeat instantiation
}
public static Singleton getInstance()
{
if (instance == null) {
instance = new Singleton();
}
return instance;
}
}
package com.myapp.mobile;
import com.myapp.mobile.Singleton;
import com.myapp.mobile.Customer;
public class MyAppApplication extends Singleton
{
private Customer mCustomer;
public Customer getCustomer()
{
return this.mCustomer;
}
public void setCustomer(Customer aCustomer)
{
this.mCustomer = aCustomer;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment