Created
January 20, 2010 18:17
-
-
Save scottferg/282070 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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