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

 

 

Compare two dimensional arrays

With this example we are going to demonstrate how to compare two dimensional arrays. We are using int arrays, but the same API applies to any types of arrays, e.g. boolean[][], byte[][], char[][], double[][], float[][], long[][], short[][] and String[][]. In short, to compare two dimensional arrays we have implemented a method as described below: The example’s method is boolean equal(final ...

Read More »

Sort arrays example

This is an example of how to sort arrays. We are using an int array in the example, but the same API applies to any type of arrays e.g. byte[], char[], double[], float[], long[], short[]. Sorting an int array implies that you should: Create an int array with elements. Invoke sort(int[] a) API method of Arrays . It sorts an ...

Read More »

Binary search Java array example

In this example we shall show you how to search an element of an array using the binary algorithm in Java. We are using an int array in the example, but the same API applies to any type of arrays e.g. byte[], char[], double[], float[], long[], short[]. We are using the binarySearch(int[] b, int value) API method of Arrays. To ...

Read More »

Convert Object Array to List example

With this example we are going to demonstrate how to convert an Object array to a List. We are using a String array in the example. In short, to convert an String array to a List you should: Create a String array with elements. Invoke asList(Object[] objArray) API method of Arrays, with the list as parameter. It returns a fixed ...

Read More »

Remove mapping from TreeMap example

This is an example of how to remove mapping from a TreeMap, that is removing a key value pair from a TreeMap. Removing mapping from a TreeMap implies that you should: Create a new TreeMap. Populate the map with elements, with put(K key, V value) API method of TreeMap. Invoke remove(Object o) API method of TreeMap with a key as ...

Read More »

Remove all mappings from TreeMap example

In this example we shall show you how to remove all mappings from a TreeMap, that is removing all key value pairs from the TreeMap. To clear a TreeMap one should perform the following steps: Create a new TreeMap. Populate the map with elements, with put(K key, V value) API method of TreeMap. Invoke clear() API method of TreeMap. The ...

Read More »

TreeMap Iterator example

With this example we are going to demonstrate how to obtain a TreeMap Iterator, that is an iterator over the key value pairs of the TreeMap. The TreeMap API provides methods to get an Iterator. In short, to obtain a TreeMap Iterator you should: Create a new TreeMap. Populate the map with elements, with put(K key, V value) API method ...

Read More »

Obtain tail map from TreeMap example

This is an example of how to obtain a tail map from a TreeMap. The TreeMap API provides methods for this operation. Obtaining a tail map from a TreeMap implies that you should: Create a new TreeMap. Populate the map with elements, with put(K key, V value) API method of TreeMap. Invoke tailMap(Object fromKey) API method of TreeMap. It returns ...

Read More »

Obtain sub Map from TreeMap example

In this example we shall show you how to obtain a sub Map from a TreeMap. The TreeMap API provides methods for this operation. To obtain a sub Map from a TreeMap one should perform the following steps: Create a new TreeMap. Populate the map with elements, with put(K key, V value) API method of TreeMap. Invoke subMap(Object fromKey, Object ...

Read More »

Get size of TreeMap example

With this example we are going to demonstrate how to get the size of a TreeMap, that is the number of key value pairs that the TreeMap contains. In short, to get the size of a TreeMap you should: Create a new TreeMap. Populate the map with elements, with put(K key, V value) API method of TreeMap. Invoke size() API ...

Read More »