LinkedList low level implementation [iii]
Problem statement: LinkedList low level implementation in java !
- class Node1 {
- Node1 next;
- int data;
- Node1(int data) {
- this.data = data;
- }
- }
- public class LinkedListLowLevelExe3 {
- public static void main(String[] args) {
- Node1 head = new Node1(2);
- Node1 h2 = new Node1(5);
- Node1 h3 = new Node1(6);
- Node1 h4 = new Node1(3);
- Node1 h5 = new Node1(9);
- head.next = h2;
- h2.next = h3;
- h3.next = h4;
- h4.next = h5;
- h5.next = null;
- System.out.print(head.data + "-->");
- System.out.print(head.next.data + "-->");
- System.out.print(head.next.next.data + "-->");
- System.out.print(head.next.next.next.data + "-->");
- System.out.print(head.next.next.next.next.data+"-->NULL");
- }
- }
Output:
2-->5-->6-->3-->9-->NULL
2-->5-->6-->3-->9-->NULL
Comments
Post a Comment