Question: d ) Assume that head references a linked list although we don't know what is currently stored in that list. Write a block of code
dAssume that head references a linked list although we don't know what is currently stored in that list. Write a block of code using a trycatch block that will work through the entire linked list printing each element out, stopping only when we have reached the end of the list because a NullPointerException is thrown. Once the Exception is thrown, output the number of elements found in the list.
plase write me a complete java code for this problemuse the following class definition of a linked list Node:
class Node
int info;
Node next;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
