GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||
GeezerVison is showing www.geeksforgeeks.org — ArrayList isEmpty() Method in Java with Examples - GeeksforGeeks ArrayList isEmpty() Method in Java with ExamplesLast Updated : 22 Jul, 2026 The isEmpty() method of the ArrayList class is used to check whether an ArrayList contains any elements. It returns true if the list has no elements; otherwise, it returns false.
Output true false Explanation: Initially, the ArrayList contains no elements, so isEmpty() returns true. After adding an element, the list is no longer empty, so it returns false. Syntax
Return Type: It returns a boolean value, Example: Using isEmpty() with an ArrayList of Strings
Output Is list empty? true Is list empty? false Explanation: The isEmpty() method checks whether the ArrayList contains any elements. After adding two strings, the method returns false. Example: Using isEmpty() with Custom Objects
Output true false Explanation: The isEmpty() method works with any type of ArrayList, including custom objects. It returns true when the list has no objects and false after an object is added. Difference Between isEmpty() and size()
Advantages of isEmpty() Method
Comment Explore | ||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |