public class LLexample1 {

// Ignore args
public static void main(String[] args)
{
// Create a LL that contains the Integers 
// 1,2,3,4,...,9,10

// First insert at the beginning and then at the end
LinearNode<Integer> ptr,old,head;

// Insert at the end of the linked list
// Create 1st node using second constructor 
// (1 actual parameter)
// Make node.next --> null and node.element --> 1

LinearNode<Integer> node=new LinearNode<Integer>(1);

// Make head point to that node
head=node;

// Insert 2 to 10
for(int i=2;i<=10;i++)
{
// Set old to current node
old=node;

// Create new LinearNode object with element i
// Note: LinearNode<Integer> node=new LinearNode<Integer>(i);
// won't work here as you would be redeclaring node!!!
// Remove the LinearNode<Integer> and the node variable
// can be made to point to other nodes.
node=new LinearNode<Integer>(i);
old.setNext(node);
}

// Traverse LL to see the Integers are in proper order
System.out.println("LLexample1: Single Linked List of Integers 1 to 10");
ptr=head;
while(ptr!=null)
   {
   System.out.println(ptr.getElement());
   ptr=ptr.getNext();
   }
}
}

