class Listnode<E> { private E data; private Listnode<E> next; public Listnode(E d) { this(d, null); } public Listnode(E d, Listnode<E> n) { data = d; next = n; } public E getData() { return data; } public Listnode<E> getNext() { return next; } public void setData(E ob) { data = ob; } public void setNext(Listnode<E> n) { next = n; } }
Create a chain of nodes containing the Strings "A", "B", and "C" (in that order) .
Assume head points to the first node in a chain of nodes containing Strings. Write a code fragment that counts the number of items in the chain of nodes.
Assume head points to the first node in a chain of nodes containing Strings. Write a code fragment that adds "last" to the end of the chain of nodes. You may assume the chain has at least one item.
Assume head points to the first node in a chain of nodes containing Strings. Write a code fragment to remove the third item from the chain of nodes. You may assume the chain has at least three items.
Assume head points to the first node in a chain of nodes containing Strings. Write a code fragment to reverse the chain of nodes.