In the last tutorial, we have seen how a Queue serves the requests based on FIFO(First in First out). Now the question is: What if… [Read More]
Queue Interface in Java Collections
A Queue is designed in such a way so that the elements added to it are placed at the end of Queue and removed from… [Read More]
Comparator Interface in Java
In the last tutorial, we have seen how to sort objects of a custom class using Comparable interface. By using Comparable we can sort the… [Read More]
Comparable Interface in Java with example
Comparable interface is mainly used to sort the arrays (or lists) of custom objects. Lists (and arrays) of objects that implement Comparable interface can be… [Read More]
Java – How to Sort a HashSet?
As we know HashSet doesn’t sort elements, in fact it displays them in random order. While dealing with HashSet we may come across a situation… [Read More]
Difference between list set and map in java?
List, Set and Map are the interfaces which implements Collection interface. Here we will discuss difference between List Set and Map in Java. List Vs… [Read More]
How to remove duplicates from ArrayList in Java
In this tutorial, you will learn how to remove duplicates from ArrayList. Example 1: Removing duplicates from ArrayList using LinkedHashSet In the following example, we… [Read More]
How to get the last element of Arraylist?
There are times when we need to get the last element of an ArrayList, this gets difficult when we don’t know the last index of… [Read More]
how to copy one hashmap content to another hashmap
In this tutorial we are gonna learn how to copy one HashMap elements to another HashMap. We will be using putAll() method of HashMap class… [Read More]
HashMap – Get value from key example
Description Program to get value from HashMap when the key is provided. Example import java.util.HashMap; class HashMapDemo{ public static void main(String[] args) { // Create… [Read More]
Difference between HashSet and HashMap
In this article we are gonna discuss the differences between HashSet and HashMap classes. HashSet vs HashMap Differences: HashSet HashMap HashSet class implements the Set… [Read More]
Difference between HashSet and TreeSet
In this article we are gonna discuss the differences between HashSet and TreeSet. HashSet vs TreeSet 1) HashSet gives better performance (faster) than TreeSet for… [Read More]
How to convert a HashSet to a TreeSet
Description Program to convert a HashSet to a TreeSet Program Here is the complete code for HashSet to TreeSet conversion. We have a HashSet of… [Read More]
Converting a HashSet to an Array
Here is the program for converting a HashSet to an array. Program import java.util.HashSet; class ConvertHashSettoArray{ public static void main(String[] args) { // Create a… [Read More]
Convert HashSet to a List/ArrayList
In this tutorial we will be learning how to convert a HashSet to a List (ArrayList). Program Here we have a HashSet of String elements… [Read More]
- « Previous Page
- 1
- 2
- 3
- 4
- …
- 11
- Next Page »