Difference between Hashtable and HashMap in Java

Here you will learn about difference between Hashtable and HashMap in Java. Both Hashtable and HashMap are data-structure based upon hashing and implementation of Map interface, and almost seems to be similar but there is significant difference between both which is described as follows. Difference between Hashtable and HashMap in Java Characteristic Hashtable HashMap Synchronization Hashtable is  synchronized internally. Synchronization means that merely one thread can change that Hashtable at one time. Fundamentally it signify that  Hashtable will have to

Read more

Difference between ArrayList and LinkedList in Java

Here you will learn about difference between arraylist and linkedlist in java i.e. arraylist vs linkedlist. Both ArrayList and LinkedList are similar in many ways like both implement List interface and are non-synchronized. But still there are various differences between them which I have discussed below. Also Read: Difference between ArrayList and Vector in Java Image Source Difference between ArrayList and LinkedList in Java ArrayList LinkedList Implementation ArrayList internally implements dynamic array to store elements. LinkedList internally implements doubly linked list

Read more

Difference between ArrayList and Vector in Java

Here you will get to know the difference between ArrayList and Vector in Java programming language. ArrayList It is a class in Java that implements List interface. Unlike traditional array data structure, it is not fixed in length and doesn’t require its size to be specified in order to declare it. They can grow and can be reduced dynamically as per need. Apart from these benefits ArrayList class has many pre-defined methods which could help the developers save a lot

Read more

Difference between Array and ArrayList in Java

Here you will learn about difference between array and arraylist in java. Both array and arraylist are most important and frequently used data structure in java. Below I have discussed about various differences between them.   Difference between Array and ArrayList in Java Property Array ArrayList Size Array is fixed in size. Once declared, its size can’t be changed. ArrayList size can be changed after declaration. For example when we add or remove element in arraylist, its size increases or

Read more

Comparable vs Comparator in Java

Here you will learn about Comparable vs Comparator in Java. Difference between Comparable and Comparator is one of the commonly asked questions in Java interviews. Both the interfaces are used to sort collection objects but still there are some differences between them which I have discussed below. Also Read: Comparable and Comparator Example Comparable vs Comparator in Java S.No Comparable Comparator 1. It is used to sort objects on the basis of only one property at a time. For example if

Read more

Java Properties File – How to Read and Write

In this tutorial you will learn about java properties file and how to perform read and write operations on it.   What is properties file? In Java related technologies, properties file is used to store configuration data or settings of application. It has .properties extension.   Why we need properties file? It makes application maintenance easier. We can change some information in application by doing changes in properties file. We don’t need to recompile the java source files. Let us

Read more

How to Sort ArrayList of Objects in Java

In this tutorial you will learn how to sort arraylist of objects in java. In our previous tutorial we have seen how to sort arraylist of String or Integer type using Collection.sort() method. Can we use that process to sort an arraylist of custom objects? The answer is big no. For doing this we have to use Comparable or Comparator interfaces. Below I have shared an example for each of them. Sort ArrayList of Objects Using Comparable Comparable is used to

Read more

How to Sort ArrayList of String and Integer in Java

In this tutorial you will learn how to sort ArrayList of String or Integer in Java. We can easily sort an arraylist in ascending or descending order using Collections.sort() method. Below I have shared simple example for each of them. Sort ArratList in Java Example to Sort ArrayList of String Below program sorts an arraylist of String type.

  Output Sort in ascending order Android IOS Linux Mac Windows Sort in descending order Windows Mac Linux IOS Android  

Read more