【发布时间】:2015-03-14 17:01:34
【问题描述】:
class A {
private List<B> list = new ArrayList<B>();
private B example;
public A(List<B> list) {
this.list = list;
this.example = setExample();
}
private B setExample() {
B object;
//do something with the list
return object;
}
}
这样的事情可能吗?该对象有一个列表,但我希望该列表的特定元素也存储在该对象中。
【问题讨论】:
标签: java methods constructor