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 ....

 

 

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 »

Date from specific time

This is an example of how to get a Date from a specific time. The class Date represents a specific instant in time, with millisecond precision. Getting a Date from a specific long time implies that you should: Create a new Date object, using the Date(long date) constructor, with a long parameter. The constructor allocates a Date object and initializes ...

Read More »

Convert Date to millisec

In this example we shall show you how to convert a Date to millisec, that means get the long number of millisec that represent a Date object. A Date object represents a specific instant in time, with millisecond precision. To convert a Date to millisec one should perform the following steps: Create a new Date object, using the Date() constructor, ...

Read More »

Compare Date objects with compareTo method

With this example we are going to demonstrate how to compare Date objects with compareTo method of the Date class. In short, to compare a Date object with another you should: Create a new Date object, using the Date() constructor, that allocates a Date object and initializes it so that it represents the time at which it was allocated, measured ...

Read More »

Compare Date objects with before method

This is an example of how to compare Date objects with before(Date when) API method of Date. Comparing a Date with another Date using before(Date when) method implies that you should: Create a new Date object, using the Date() constructor, that allocates a Date object and initializes it so that it represents the time at which it was allocated, measured ...

Read More »

Compare Date objects with after method

In this example we shall show you how to compare Date objects with after(Date when) method of Date, that tests if a Date is after the specified one. To compare a Date object with another Date object, using after(Date when) API method of Date one should perform the following steps: Use the simple Date() constructor, to allocate a Date object ...

Read More »