开发模式:单例模式

饿汉式单例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
public class Hungry{

private byte[] data1 = new byte[1024*1024];
private byte[] data2 = new byte[1024*1024];
private byte[] data3 = new byte[1024*1024];
private byte[] data4 = new byte[1024*1024];

private Hungry(){

}
private final static Hungry HUNGRY = new Hungry();

public static Hungry getInstance(){
return HUNGRY;
}
}

扫一扫,分享到微信

微信分享二维码

请我喝杯咖啡吧~

支付宝
微信