扫码关注官方订阅号
数据项目结构为
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'); ...
这样写比较麻烦,有没有简便一点的写法?
Arrays.asList()但是你还要new 100个Item。把内容写到某个地方,然后用个代码来创建。
你把这100个值写到txt文件中,然后使用java代码读取txt文件,将取到的内容,初始化到list中,如果你对读写非常熟悉的话,分分钟就可以搞定的哈。
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
Arrays.asList()
但是你还要new 100个Item。
把内容写到某个地方,然后用个代码来创建。
你把这100个值写到txt文件中,然后使用java代码读取txt文件,将取到的内容,初始化到list中,如果你对读写非常熟悉的话,分分钟就可以搞定的哈。