1public class Main{ class Node{ int data; Node next; public Node(int data) { this.data = data; this.next = null; } } public Node first = null; public Node last = null; public void addNode(int data){ Node newNode = new Node(data); if(first == null) { first = newNode; last = newNode; } else { last.next = newNode; last = newNode; } } public void deleteFromStart(){ if(first == null) { System.out.println("List is empty"); return; } else { if(first != last) { first = first.next; } else { first = last = null; } } } public void display() { Node current = first; if(first == null) { System.out.println("List is empty"); return; } while(current != null) {System.out.print(current.data + " "); current = current.next; } System.out.println(); } public static void main(String[] args) { Main sList = new Main(); sList.addNode(2); sList.addNode(4); sList.addNode(6); sList.addNode(8); System.out.println("Original List"); sList.display(); while(sList.first != null) { sList.deleteFromStart(); System.out.println("After list element deleted"); sList.display(); } } }