public class Singleton1
extends java.lang.Object
data
.TestSingleton1
Modifier and Type | Field and Description |
---|---|
private int |
data
An instance attribute - for illustrative purposes
|
protected static Singleton1 |
uniqueInstance
The protected reference to the one and only instance.
|
Modifier | Constructor and Description |
---|---|
protected |
Singleton1()
The constructor is protected so that it is controlled by the class.
Initially the data value is set to 0. |
Modifier and Type | Method and Description |
---|---|
int |
getData()
data getter method |
static Singleton1 |
instance() |
void |
setData(int d)
data setter method |
protected static Singleton1 uniqueInstance
private int data
protected Singleton1()
data
value is set to 0.public static Singleton1 instance()
public int getData()
data
getter methodpublic void setData(int d)
data
setter methodd
- defines the new data value