本文介绍了类型不匹配:不能转换对象名单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 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

我需要阅读的内部单独值1 for循环我怎么能这样做呢?

I need to read value of 1 alone inside of for loop how can i do this ?

推荐答案

您必须类型转换列表

for(int k=0;k<=companyList.size();k++){

List companyId =(List)companyList.get(k);

这篇关于类型不匹配:不能转换对象名单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 16:31