怎么将 object类型转换为 ArrayList<gt;类型
展开全部
Object date=pagelist.getResult();
返回类型要明确,不要强转,鬼知道返回的类型是什么
使用泛型吧
public class ServiceResult<T>{
private String resultMsg="";
private int resultCode="";
private T result;
public T getResult(){
return result;
}
public void setResult(T returnObj){
this.result=returnObj;
}
}
...
ServiceResult<ArrayList<Jibing>> date=pagelist.getResult();
ArrayList<Jibing> list = date.getResult();
if (list != null && list.size() > 0)
{
for (int i = 0; i < list.size(); i++)
{
Jibing m = (Jibing)list.get(i);//报错
}
}
返回类型要明确,不要强转,鬼知道返回的类型是什么
使用泛型吧
public class ServiceResult<T>{
private String resultMsg="";
private int resultCode="";
private T result;
public T getResult(){
return result;
}
public void setResult(T returnObj){
this.result=returnObj;
}
}
...
ServiceResult<ArrayList<Jibing>> date=pagelist.getResult();
ArrayList<Jibing> list = date.getResult();
if (list != null && list.size() > 0)
{
for (int i = 0; i < list.size(); i++)
{
Jibing m = (Jibing)list.get(i);//报错
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询