Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package oct18;
- public class TestProgram {
- public static void main(String[] args) {
- Node<Integer> inthead = new Node<Integer>(3, null);
- Node<Integer> inttail = inthead;
- inthead = new Node<Integer>(2, inthead);
- inthead = new Node<Integer>(1, inthead);
- inttail.next = inthead;
- Node<Integer> noderef = inthead;
- do {
- System.out.println(noderef.data);
- noderef = noderef.next;
- } while (noderef != inthead);
- Node<String> stringhead = new Node<String>("Cher", null);
- Node<String> stringtail = stringhead;
- stringhead = new Node<String>("Bob", stringhead);
- stringhead = new Node<String>("Alice", stringhead);
- stringtail.next = stringhead;
- Node<String> stringref = stringhead;
- for (int j = 0; j < 2; j++) {
- for (int i = 0; i < 3; i++) {
- System.out.println(stringref.data);
- stringref = stringref.next;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement