Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!

 

1. JPA Mini Book

2. JVM Troubleshooting Guide

3. JUnit Tutorial for Unit Testing

4. Java Annotations Tutorial

5. Java Interview Questions

 

and many more ....

 

 

Remove all elements from ArrayList example

With this example we are going to demonstrate how to remove all elements from an ArrayList, that means clearing the arrayList. In short, to clear an ArrayList you should: Create a new ArrayList. Populate the arrayList with elements, using add(E e) API method of ArrayList. Invoke clear() API method of ArrayList. The method removes all of the elements from this ...

Read More »

ArrayList ListIterator example

This is an example of how to obtain an ArrayList ListIterator. The ListIterator is an iterator for lists that allows the programmer to traverse the list in either direction, modify the list during iteration, and obtain the iterator’s current position in the list. Obtaining an ArrayList ListIterator implies that you should: Create a new ArrayList. Populate the arrayList with elements, ...

Read More »

ArrayList Iterator example

In this example we shall show you how to obtain an ArrayList Iterator, that is an iterator over the elements of the ArrayList. To obtain an ArrayList Iterator one should perform the following steps: Create a new ArrayList. Populate the arrayList with elements, using add(E e) API method of ArrayList. Use iterator() API method to obtain the Iterator of the ...

Read More »

Insert all elements of Collection to specific ArrayList index

With this example we are going to demonstrate how to insert all elements of a Collection to a specific ArrayList index. We are using the Vector as a Collection implementation. In short, to insert all elements of a Vector to a specific ArrayList index you should: Create a new ArrayList. Populate the arrayList with elements, using add(E e) API method ...

Read More »

Get sub list of ArrayList example

This is an example of how to get a subList of an ArrayList, that is a list containing elements from a startIndex to an endIndex of the ArrayList. Getting a subList of an ArrayList implies that you should: Create a new ArrayList. Populate the arrayList with elements, using add(E e) API method of ArrayList. Use the subList(int startIndex, int endIndex) ...

Read More »

ArrayList size example

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

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

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

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 »

Get Date

With this example we are going to demonstrate how to get a Date in Java. The class Date represents a specific instant in time, with millisecond precision. In short, to get a Date object you should: Create a new Date object, using the Date() constructor. The constructor allocates a Date object and initializes it so that it represents the time ...

Read More »