如何转换列表项= new List();列出?你能帮我吗?
答案 0 :(得分:0)
List<Doctor> items = new List();
---将数据添加到items
列表中---
然后
List<String> strings = new ArrayList<>(items.size());
for (Doctor doctor: items) {
strings.add(Objects.toString(doctor, null));
}
如果您使用的是Java 8,
List<String> strings = items.stream()
.map(doctor -> Objects.toString(doctor , null))
.collect(Collectors.toList());
答案 1 :(得分:0)
https://api.dartlang.org/stable/2.4.0/dart-core/List-class.html
^使用.map
实例的List<Doctor>
方法。
例如
var itemStrings = items.map((doc) {
// Title property as example
return doc.title;
}).toList();
我建议您服用dart language tour