类型不匹配:无法从对象转换为列表 [英] Type mismatch: cannot convert from Object to List
本文介绍了类型不匹配:无法从对象转换为列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
CompanyDAO companyDAO = new CompanyDAO();
List companyList = companyDAO.getAllCompanyList();
MycompanyList 包含这样的数据:
MycompanyList contains a data of like this :
[[1, Agastha Medical Center], [2, Agastha Asthma]]
现在我想迭代这些值,我想将值 1 传递给查询,但是当我将它放在 for 循环中时,我得到了
Now i want to iterate the values and i want to pass a value of 1 to query but when i am placing this inside of a for loop i am getting
for(int k=0;k<=companyList.size();k++){
List companyId =companyList.get(k); // [1, Agastha Medical Center] for k=0;
Type mismatch: cannot convert from Object to List
我需要在 for 循环中单独读取 1 的值,我该怎么做?
I need to read value of 1 alone inside of for loop how can i do this ?
推荐答案
you have to type cast the list
you have to type cast the list
for(int k=0;k<=companyList.size();k++){
List companyId =(List)companyList.get(k);
这篇关于类型不匹配:无法从对象转换为列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文