数据项目结构为
public Item(String id, String content, String details) {
this.id = id;
this.content = content;
this.details = details;
}
现在有100个值,想初始化到ArrayList
list.add(new Item('key','digest','detail');
...
这样写比较麻烦,有没有简便一点的写法?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
Arrays.asList()
但是你还要new 100个Item。
把内容写到某个地方,然后用个代码来创建。
你把这100个值写到txt文件中,然后使用java代码读取txt文件,将取到的内容,初始化到list中,如果你对读写非常熟悉的话,分分钟就可以搞定的哈。