I need to create a list which contains objects of a particular class. I am having problem in retrieving the objects back from the list.
Here is my code for insertion into list-
import java.util.LinkedList;
import java.util.ListIterator;
public class listchek {
int i;
String name;
public listchek(int k, String n)
{
i=k;
name=n;
}
static LinkedList<listchek> list;
public static void add(listchek lc)
{
list.add(lc);
}
public static void getlistelements()
{
}
}
class insert
{
public static void main(String arg[])
{
listchek ob1=new listchek(1, "first");
listchek ob2=new listchek(2, "sec");
listchek ob3=new listchek(3, "third");
listchek ob4=new listchek(4, "fourth");
listchek.add(ob1);
listchek.add(ob2);
listchek.add(ob3);
listchek.add(ob4);
}
}
How do i get the object values back from list?