Difference between revisions of "CSC212 Lab 6 Solutions 2014"
Line 5: | Line 5: | ||
=Problem 2= | =Problem 2= | ||
<br /> | <br /> | ||
− | + | <source lang="java"> | |
− | <source lang="java"> | ||
class IntSLLNode { | class IntSLLNode { | ||
Line 16: | Line 15: | ||
− | public class | + | public class MyLinkedList { |
IntSLLNode head, tail; | IntSLLNode head, tail; | ||
int length; | int length; | ||
− | public | + | public MyLinkedList() { |
head = tail = null; | head = tail = null; | ||
length = 0; | length = 0; | ||
Line 73: | Line 72: | ||
public static void main(String[] args) { | public static void main(String[] args) { | ||
− | + | MyLinkedList L = new MyLinkedList(); | |
L.printStatus( "Brand new list" ); | L.printStatus( "Brand new list" ); | ||
Line 82: | Line 81: | ||
L.printStatus( "After adding 10, 20, ... to tail..."); | L.printStatus( "After adding 10, 20, ... to tail..."); | ||
− | L = new | + | L = new MyLinkedList(); |
L.printStatus( "Brand new list" ); | L.printStatus( "Brand new list" ); | ||