Jibing m = (Jibing)list.get(i); The strong transfer in front of this sentence is redundant, the list itself stores Jibing. The error reported should be ClassCastException, then the problem lies in the sentence ArrayList<Jibing> list =(ArrayList<Jibing>)date;, which shows that date is a set, but the set is not Jibing, so you can force it to be converted to ArrayList, but when When you get the elements inside, you can't force it to Jibing.
Object date=pagelist.getResult(); The return type must be clear, don’t force it, who knows what the return type is Use generics
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);//报错
}
}
Force transfer is easy to report errors, you need to make sure the data is suitable for forced transfer
What specific function is to be achieved?
list.get() put parentheses, the execution order is obviously wrong.
Jibing m = (Jibing)list.get(i); The strong transfer in front of this sentence is redundant, the list itself stores Jibing. The error reported should be ClassCastException, then the problem lies in the sentence ArrayList<Jibing> list =(ArrayList<Jibing>)date;, which shows that date is a set, but the set is not Jibing, so you can force it to be converted to ArrayList, but when When you get the elements inside, you can't force it to Jibing.
Object date=pagelist.getResult();
The return type must be clear, don’t force it, who knows what the return type is
Use generics
It depends on what type your date is finally returned, and convert it according to the type.