- import java.util.ArrayList;
- public class RemoveAllElementsOfArrayListExample {
- public static void main(String[] args) {
- //create an ArrayList object
- ArrayList arrayList = new ArrayList();
- //Add elements to Arraylist
- arrayList.add("1");
- arrayList.add("2");
- arrayList.add("3");
- System.out.println("Size of ArrayList before removing elements : "
- + arrayList.size());
- /*
- To remove all elements from the ArrayList use
- void clear() method.
- */
- arrayList.clear();
- System.out.println("Size of ArrayList after removing elements : "
- + arrayList.size());
- }
- }
Search This Blog
Labels
- Apache Http Client (4)
- Array (3)
- Array List (12)
- Assertion (2)
- Calendar (20)
- Collection (7)
- Common Sol (14)
- Core Java (36)
- Date (4)
- Design Pattern (2)
- Display Tag (4)
- Eclipse (3)
- Enum (2)
- Exception Handling (5)
- How To (6)
- HttpURLConnection (2)
- ImageIO (2)
- Inner Class (1)
- Java Interview Q (1)
- Java IO (6)
- Java Mail (4)
- JDBC (1)
- JSON (5)
- JSP (2)
- JSTL (2)
- MYSQL (1)
- Platform Environment (3)
- Reg Ex (1)
- Serialization (1)
- Servers (3)
- Servlet JSP (3)
- Singleton Pattern (2)
- SQL (2)
- String Handling (11)
- Struts (5)
- Synchronization (5)
- Threads (6)
- Web Services (3)
0 comments:
Post a Comment