This program travers the linked list and print the value component (= field) in the List object:
// The List object class:
public class List
{
int value;
List next;
// instance methods omitted - not relevant for discussion
}
|
A similar Java program should have been taught in CS171....
(I'm not a prophet, so I don't know what example the professor used in CS171. But he/she should have explained each of the statement that I used in the program and what the effect is of the statement)
How to run the program:
|
|
|
Note:
|
|
Note:
|
We have discussed the reference concept already - see: click here