假设我已经通过
创建了一个对象SpecialResource数组ArrayList<SpecialResource> masterRes = new ArrayList<SpecialResource>();
masterRes.add(0, new SpecialResource(3,5,0,"Foo Bar"));
.........etc etc many more adds...
假设SpecialResource有一个名为getMax()
我如何引用数组索引0的getMa
x方法?我猜到的每个排列都会产生语法错误。 masterRes<0>.getMax()
,masterRes(0).getMax()
等
答案 0 :(得分:2)
嗯,实际上,它不是一个数组,而是一个集合。而且,为了按索引检索项目,您必须使用get
方法:
masterRes.get(0).getMax();
答案 1 :(得分:0)
masterRes.get(0).getMax();
Java / Android API文档将为您提供帮助。
http://androidappdocs.appspot.com/reference/java/util/ArrayList.html