How do you empty an arraylist?
Answer / Mritunjay Kumar Pandey
To empty an ArrayList, you can either use the clear() method or set its size to zero. Here are examples of both methods:
1. using clear():nArrayList<String> myList = new ArrayList<>();nmyList.add("apple");nmyList.clear();
2. setting size to zero:nArrayList<String> myList = new ArrayList<>();nmyList.add("apple");nmyList.size() = 0;
| Is This Answer Correct ? | 0 Yes | 0 No |
Define an equivalence relation?
What is mean by sorting?
What are the main differences between the linked list and linear array?
What do you mean by hash table?
What are data members?
Why do we study data structures?
Is arraylist a collection?
Is hashmap keyset ordered?
What is the complexity of arraylist?
What is comparable interface?
Which sort is best for linked list?
Q#1: An algorithm is made up of 2 modules M1 and M2.If order of M1 is F(n) and order of M2 is g (n) then what is the order of the algorithm. Q # 2 : How many binary trees are possible with 3 nodes? with 4 nodes?