OK, this is driving me nuts! The are three classes: Node, LinkedList and Test.
Node is...the node:
class IntNode{
private int data; //variable to store an integer value.
private Node link; //variable to store an IntNode object.
public IntNode( int initData, Node initLink ){
data = initData;
link = initLink;
}
}//end class Node
the constructor is LinkedList (NOTE: public LinkedList is empty) and contains node position stuff like add before, get next, etc.:
class LinkedList{
public LinkedList( ){
}
public add(){
....adds nodes.....this works
}
}//end class LinkedList
class Test has main, takes in values and is supposed to split all the values into two seperate linked lists and sort them...
public class Test {
public static void main(String[] args) throws FileNotFoundException{
IntLinkedList list = new IntLinkedList();
list = getListFrom("project2.txt"); - this just adds nodes and works
IntLinkedList first = new IntLinkedList();
}
}//end class Test
I omitted some code for simplicity, the question I have is, when I add Nodes to list, it contains 29 elements, after I declare first, everything in list is gone...it's like they are the same thing. Why is that? How can I have a linked list list and a linked list first? Sorry for the stupidity.