COMPSCI 61B Lecture Notes - Lecture 4: Infinite Loop, Rotary Valve
Document Summary
While functional, naked linked lists like the intlist is hard to use. Users of this class are probably going to need to know references very well and use recursion well. It"s better to make a list easier to work. Instead of intlist class, have an intnode class. Next thing we"re going to do, is create another class called sllist. An sllist is a list of integers which hides the terrible truth of the nakedness within public class sllist { public intnode first; public sllist(int x) { Did not have to specify null, just have to specify an x. Intnode x = new intnode(10, null) vs. sllist y = new sllist(10); Programmer who uses this data structure need not worry about recursion or references. First = new intnode(x, null); public sllist(int x) { first. item; first = newintnode(x, first); /adds x to the front of the list; public void addfirst(int x) {