Please help me understand, the below code is showing Type mismatch: “cannot convert from element type Object to List” in the for statement. I know I’m missing something silly. Please help.
public void setMapPriceValue(SolrItemVO solrItemVO, ArrayList proce1) throws SolrDAOException
{
List xcatentAttrList = (List<Xcatentattr>) proce1.get(0);
solrItemVO.setMapPrice(-1); // setting default value
for(List xcatentattr : xcatentAttrList){
if(xcatentattr.get(0) == 33)
solrItemVO.setMapPrice(xcatentattr.get(1));
solrItemVO.setMapPriceVal(xcatentattr.get(2));
}
}
If you are going to type things try and keep them typed
then the answer might be clearer 😉
The for loop is of type Xatentattr. You are looping through the list of that type.
Take a look at this link for more info on for-each loops