im trying to build my own LL, not seeming to work?
My insert method is wrong, and cant fiugre it out, any ideas?
public class List {
private int size;
private Node root;
private Node current;
public List(){
size = 0;
}
public void insert(int a){
size++;
if(root == null){
root = new Node(a);
current = root;
}
else{
while(current != null){
current = current.next;
}
current = new Node(a);
}//else
}//insert
public void o(){
Node c = root;
while(c != null){
System.out.println(c.data);
c = c.next;
}
}
private static class Node{
private int data;
private Node next;
public Node(int d){
data = d;
next = null;
}
}//node class
public static void main(String[] args){
List l = new List();
l.insert(1);
l.insert(2);
l.insert(3);
l.o();
}//main
}//list class
BTW: this new tagging for code sux