/**
* Notes:扩展的ArrayList类,方便在页面上进行显示.
* @author:
* @version:
*/
public class CommonArrayList extends ArrayList{
Class clazz; // 容器内保存的类
/**
* 私有构造函数,保证外界无法直接实例化
*/
private CommonArrayList() {
}
public CommonArrayList(Class clazz) {
this.clazz = clazz;
}
/**
* save the updates of customer types.
*/
public Object get(int index) {
try {
if (super.size() < index + 1) {
int cnt = index + 1 - super.size();
for (int i = 0; i < cnt; i++) {
super.add(clazz.newInstance());
}
}
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return super.get(index);
}
}
* Notes:扩展的ArrayList类,方便在页面上进行显示.
* @author:
* @version:
*/
public class CommonArrayList extends ArrayList{
Class clazz; // 容器内保存的类
/**
* 私有构造函数,保证外界无法直接实例化
*/
private CommonArrayList() {
}
public CommonArrayList(Class clazz) {
this.clazz = clazz;
}
/**
* save the updates of customer types.
*/
public Object get(int index) {
try {
if (super.size() < index + 1) {
int cnt = index + 1 - super.size();
for (int i = 0; i < cnt; i++) {
super.add(clazz.newInstance());
}
}
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return super.get(index);
}
}