PHPz2017-04-17 17:00:01
Jibing m = (Jibing)list.get(i);這句前面的強轉是多餘的,list本身存的就是Jibing。報錯應該就是ClassCastException,那麼問題就是出在了ArrayList
PHP中文网2017-04-17 17:00:01
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);//报错
}
}