Quantcast
Browsing latest articles
Browse All 11 View Live

Get Synchronized Map example

With this example we are going to demonstrate how to get a synchronized Map. We are using a HashMAp as example, but the same API applies to any type of Map implementation class e.g. TreeMap etc. The...

View Article


Get Synchronized Set example

In this example we shall show you how to get a Synchronized Set. We are using a HashSet, but the same API applies to any type of Set implementation. The Collections API provides us with methods so as...

View Article


Get unmodifiable Collection

This is an example of how to get an unmodifiable Collection. The same API applies to any type of Collection implementation classes e.g. HashSet, TreeSet, LinkedHashSet, LinkedList etc. Nevertheless...

View Article

Binary search List example

With this example we are going to demonstrate how to Binary search a List. We will use the binarySearch(List list, T key) API method of the Collections class. Collections provides static methods that...

View Article

Replace all elements of List example

In this example we shall show you how to replace all elements of a List. We will use the fill(List list, Object element) API method of the Collections class. Collections provides static methods that...

View Article


Replace specific element of List example

This is an example of how to replace a specific element of a List. We will use the replaceAll(List list, Object oldVal, Object newVal) API method of the Collections class. The ArrayList is used as a...

View Article

Reverse order of List example

With this example we are going to demonstrate how to reverse the order of a List. This is provided by the reverse(List list) API method of the Collections class. The ArrayList is used as a List...

View Article

Shuffle List elements example

In this example we shall show you how to shuffle a List’s elements. This is provided by the shuffle(List list) API method of the Collections class. The Collections class provides static methods that...

View Article


Swap List elements example

This is an example of how to swap a List’s elements . We are using the swap(List list, int i, int j) method of the Collections Class. Collections provides static methods that operate on or return...

View Article


Java Sorted List Example

In this example, I will show how to sort a java.util.List using methods of java.util.Collections class. SimpleSortExample Create a Java class called SimpleSortExample with the following source code....

View Article
Browsing latest articles
Browse All 11 View Live