import java.util.LinkedList; public class Example { public static void main(String[] args) { LinkedListlist = new LinkedList (); // Adding elements to the LinkedList list.add("Java"); list.add("Python"); list.add("JavaScript"); // Checking if the LinkedList is empty or not if(list.isEmpty()) { System.out.println("LinkedList is empty"); } else { System.out.println("LinkedList is not empty"); } } }
import java.util.LinkedList; public class Example { public static void main(String[] args) { LinkedListOutput: LinkedList is empty Package library: java.utillist = new LinkedList (); // Checking if the LinkedList is empty or not if(list.isEmpty()) { System.out.println("LinkedList is empty"); } else { System.out.println("LinkedList is not empty"); } } }