We were giving a sample link list to play around with for class. When running the program, the last line of the print out says:
List After adding a Node: 7 6 5 4 3 2 1 0
However I added a method called stepOne that is suppose to swap positions of the 5 and the 4 in order that it would print out
List After adding a Node: 7 6 4 5 3 2 1 0
However I don't get this print out.
List After adding a Node: 7 6 5 4 3 2 1 0
However I added a method called stepOne that is suppose to swap positions of the 5 and the 4 in order that it would print out
List After adding a Node: 7 6 4 5 3 2 1 0
However I don't get this print out.
Code:
public void stepOne(){
Node position=first;
while(position.data!=5 && position!=null){
position=position.next;
position.next=position;
}
position=first.next.next;
position.next.next=position;
}
Comment