Java Reference
In-Depth Information
13.
a. No. The default constructor creates an empty list. If it set nextNode to firstNode , nextNode would be set
to null .
b. Yes, but with a disadvantage. Each addition to the list would set nextNode to firstNode . After creating a list,
you could traverse it. However, the only way you could reset the traversal to the list's beginning would be to
add another entry to the list.
14.
while (traverse.hasNext())
traverse.next();
while (traverse.hasPrevious())
System.out.println(traverse.previous());
15.
traverse.next(); // return Jim
traverse.next(); // return Josh
traverse.set("Jon"); // replace Josh
16.
traverse.next(); // return Jim
traverse.add("Miguel"); // add Miguel after Jim
Search WWH ::




Custom Search