public class Singleton3
extends java.lang.Object
data
.TestSingleton3
Modifier and Type | Field and Description |
---|---|
private int |
data
An instance attribute - for illustrative purposes
|
private static Singleton3 |
instance
The reference to the one and only instance.
|
Modifier | Constructor and Description |
---|---|
private |
Singleton3()
The constructor is private 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 Singleton3 |
instance() |
void |
setData(int d)
data setter method |
private static final Singleton3 instance
private int data
private Singleton3()
data
value is set to 0.public static Singleton3 instance()
public int getData()
data
getter methodpublic void setData(int d)
data
setter methodd
- defines the new data value