Q
提取子列表
0
A
回答
1
只是一个示例代码
List<ImageVertex> allImageList = new ArrayList<ImageVertex>();
for (Vertex vertex : allVertex) {
if (vertex instanceof ImageVertex) {
allImageList.add((ImageVertex) vertex);
}
}
1
因为ArrayList<ImageVertex>
不是ArrayList<Vertex>
的subtype。
可能的解决方案将是:
ArrayList<ImageVertex> allImageList= new ArrayList<>();
for (Vertex vertex: allVertex.sublist(0,j)) {
if (vertex instanceof ImageVertex) {
allImageList.add((ImageVertex) vertex);
}
}
相关问题
- 1. 提取子表
- 2. 提取因子列
- 3. Python列表处理来提取子
- 4. 提取孩子href到BeautifulSoup列表
- 5. 提取列表
- 6. Python从嵌套列表中提取所有子列表
- 7. R提取列表和子列表的成员(S4类)
- 8. 从主列表中递归提取子列表
- 9. Java:基于模式提取数组列表子列表
- 10. 提取子序列Python
- 11. 提取列表值
- 12. 从列表子元素列表中提取矩阵,保留矩阵的列表/子列表索引
- 13. 如何从列表中提取子类及其所有子类?
- 14. 提取列表中的列表
- 15. 提取子集提取
- 16. Haskell HXT提取值列表
- 17. sql提取xml表单列
- 18. 提取列表元素
- 19. 提取XML在MySQL表列
- 20. 提取x和从列表
- 21. 列表提取元素
- 22. 提取对象从列表
- 23. 合并和提取列表
- 24. F#:提取从列表
- 25. 链接提取列表
- 26. 提取内容的列表
- 27. 提取CKAsset列表Swift
- 28. 提取列表名称
- 29. 提取的String []从列表
- 30. 提取子表从表中的iMacros
由于'allVertex'还可以含有'TagVertex'和'ImageVertex'和java无法搞清楚在编译时间。 – lifus 2013-04-25 19:50:43
@lifus有什么建议吗? – nawara 2013-04-25 19:55:31
用于for instanceof的循环。顺便说一下,塔尔萨拉回答了比我更清楚的问题。 – lifus 2013-04-25 19:56:56