I am getting an error on this line:-"for(Item item:Items)" on "Items" keyword and the error is "Type mismatch: cannot convert from element type Object to Item". somebody Please help me out for this.
import java.util.ArrayList;
public class Model
{
public static ArrayList Items;
public static void LoadModel()
{
Items=new ArrayList();
Items.add(new Item(1, "taj.png", "Taj Mahal", "arrow.png"));
Items.add(new Item(2, "agra_fort.png", "Agra Fort", "arrow.png"));
Items.add(new Item(3, "chini _ka_rauza.png", "Chini ka Rauza", "arrow.png"));
Items.add(new Item(4, "fatepur_sikri.png", "Fatepur Sikri", "arrow.png"));
Items.add(new Item(5, "guru_ka_tal.png", "Guru Ka Tal", "arrow.png"));
Items.add(new Item(6, "jamma_masjid.png", "Jamma Masjid", "arrow.png"));
Items.add(new Item(7, "mankameshwar_temple.png", "Mankameshwar", "arrow.png"));
Items.add(new Item(8, "mehtab_baug.png", "Mehtab Baug", "arrow.png"));
Items.add(new Item(9, "musamman_burj.png", "Musamman Burj", "arrow.png"));
Items.add(new Item(10, "panch_mahal.png", "Panch Mahal", "arrow.png"));
}
public static Item GetbyId(int id)
{
for(Item item:Items)
{
if(item.id==id)
{
return item;
}
}
return null;
}
}