Java Collection

Category Archives: Java Collection

How to Compare Two Arrays in Java

Let’s see, How can you compare Two Arrays in Java to verify,  If they are equal to each other or not. Please note you can’t compare a String array to an int array. You can compare the Array only if they have the same data type.   Compare Two Arrays in Java To compare two … Continue reading How to Compare Two Arrays in Java

Find Largest and Smallest Number in Array

Let’s see, How can you find largest and smallest number in Array. Understanding of array data structure is very important for any software developer or Automation Test Engineer. Find smallest and largest number in the Array is one of favorite Interview question in Java Programming. In this program, you need to write a method, which … Continue reading Find Largest and Smallest Number in Array

Properties Class in Java

Let’s learn about the Properties Class in Java.  Normally, Java properties file is used to store project configuration data or settings. The properties object contains key-value pair both as a string. It is the subclass of Hashtable. The Properties class provides methods to get data from the properties file and store data into the properties file. It can … Continue reading Properties Class in Java

ArrayList vs Vector

In this Java tutorial, we will discuss the difference between ArrayList and Vector. ArrayList and Vector both implements List interface and maintains insertion order and both use Array as a data structure internally. However, there are few differences in the way they store and process the data. In this post, we will discuss the difference and … Continue reading ArrayList vs Vector

Difference in Hashtable and HashMap

In the previous tutorials. We have learned about the HashMap and HashTable. In this tutorial, we will learn about the Similarities and Differences in HashMap and HashTable.   We will also see When to use hashmap and when to use a hashtable. Although both classes implement the Map in java there are some key differences in … Continue reading Difference in Hashtable and HashMap

TreeMap in Java

TreeMap in Java implements the NavigableMap interface of the Map interface.  TreeMap is Red-Black tree based NavigableMap implementation. The main difference between HashMap and TreeMap is that HashMap is an unordered collection while TreeMap is sorted in the ascending order of its keys.   TreeMap is unsynchronized collection class which means it is not suitable for … Continue reading TreeMap in Java

HashMap vs ArrayList

In the tutorial, you will learn about the difference in HashMap and ArrayList or HashMap vs ArrayList in Java.   HashMap and ArrayList are two different Collection class in Java. They both used to store objects but they are completely different on their implementation and working. The main difference between ArrayList and HashMap is that ArrayList is index based data-structure backed by Array while HashMap is map data structure which works … Continue reading HashMap vs ArrayList

Serialize vs Synchronized HashMap

In the tutorial, we will discuss Serialize vs synchronized HashMap in Java with an example.   Serialized HashMap in Java HashMap class is serialized by default which means we need not implement Serializable interface in order to make it eligible for Serialization. Let’s discuss the serialization and De-serialization first.   Serialization  – Serialization is a process of … Continue reading Serialize vs Synchronized HashMap