d-m*_*man 3 java collections list
Java Spring Collection
List<CustomObject> myList = new ArrayList<CustomObject>(1000); // list with thousnda objects
Run Code Online (Sandbox Code Playgroud)
我想设置列表中所有对象的CustomObject属性'type'.简单的方法是运行循环并设置如下属性.
for(CustomObject obj:myList){
obj.setType('value');
}
Run Code Online (Sandbox Code Playgroud)
我想让代码看起来更好一点,所以如果有任何其他方式在一行代码中做同样的事情?