Home » Core Java » util » ArrayList » Page 2

ArrayList

ArrayList size example

Bipartite Graph

In this example we shall show you how to get the ArrayList size, that is the number of elements that the ArrayList contains. To get the ArrayList size one should perform the following steps: Create a new ArrayList. Populate the arrayList with elements, using add(E e) API method of ArrayList. Use the size() API method of ArrayList. The method returns ...

Read More »

Convert ArrayList to Object array example

Bipartite Graph

With this example we are going to demonstrate how to convert an ArrayList to Object array. The array will contain all of the elements existing in the ArrayList. In short, to convert an ArrayList to Object array you should: Create a new ArrayList. Populate the arrayList with elements, using add(E e) API method of ArrayList. Use toArray() API method of ...

Read More »

Append all elements of a Collection to ArrayList example

Bipartite Graph

This is an example of how to append all elements of a Collection to an ArrayList. We are using the Vector as a Collection implementation. Appending all elements of a Vector to an ArrayList implies that you should: Create a new ArrayList. Populate the arrayList with elements, using add(E e) API method of ArrayList. Create a new Vector. Populate the ...

Read More »

Add element to specified index of ArrayList example

Bipartite Graph

In this example we shall show you how to add an element to a specified index of an ArrayList. To add an element to a specified index of an ArrayList one should perform the following steps: Create a new ArrayList. Populate the arrayList with elements, using add(E e) API method of ArrayList. Invoke add(int index, E element) API method of ...

Read More »