I get this error:
java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.lang.String
This is the code:
public static List<String>produit_cart(ArrayList l)
{
List<String>re=new ArrayList();
List<String>l4=new ArrayList();
re=(List<String>) l.get(0);
for(int i=1;i<l.size();i++)
{
l4=new ArrayList();
for(int j=0;j<re.size();j++)
{
for(int k=0;k<((ArrayList)l.get(i)).size();k++)
{
l4.add(re.get(j) +
" " +
(String)((ArrayList)l.get(i)).get(k));
}
}
re=new ArrayList();
for(int m=0;m<l4.size();m++)
{
re.add(l4.get(m));
}
}
return re;
}
The problem is in this line:
l4.add(re.get(j)+" "+(String)((ArrayList)l.get(i)).get(k));
I tried to rewrite it as:
l4.add(re.get(j)+" "+((ArrayList)l.get(i)).get(k));
but it didn't work. What should I do ?