Posts

Showing posts with the label all method of link list in java

all method of link list in java

link list link list is a dynamic data structure so in link list we can add element in run time.here we will implement how to implement node link list class Node{ public int data;//data public Node next;//next Node()//constructor { data=0; next=null; } Node(int data,Node next)//constructor { this.data=data; this.next=next; } //set data public void setData(int val) { data=val; } public Node setNext(Node n) {return next=n;} public int getData() {int val=data;return val;} public Node getNext() { return next;} public String toString() { return "data="+data; } }//end of node is link list is empty.  public boolean isEmpty() { return start==null; } add element at first position of link list. //insert at first position. public void insertAtFirst(int val) { Node tt=new Node(val,start); start=tt; size++; } //insert at last public void insertAtLast(int val) { Node n,t; t=start; n=new Node(val,null); if(isEmpty()) { sta...