我有一个 public ArrayList<Spheres> sphereList = new ArrayList<Spheres>(10);
类的 ArrayList我需要从类 Spheres
中调用一个方法更新 sphereList
中的所有元素.这可能吗?如果可以,我将如何去做?如果不可能,是否有我应该采取的替代方法?
最佳答案
sphereList.stream().forEach(x -> x.callMethodFromSphere());
关于java - 是否可以从类型为 Class 的 ArrayList 中调用方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32126172/