public class orderedList
{private ListNode front = null;


public void add(int n)
 {ListNode before,after;
     if (front ==null || n < ((Integer)front.getValue()).intValue())
       {front = new ListNode(new Integer(n),front);
        }
   else
     {before = front;
      after = front.getNext();
      while (after != null && n > ((Integer)after.getValue()).intValue())
        {before = after;
         after = after.getNext();
        }
     before.setNext(new ListNode(new Integer(n),after));
    }
}
    
 public void print()
  {ListNode temp = front;
   while (temp != null)
     {System.out.println(temp.getValue());
       temp = temp.getNext();
    }
}  
}