How HashMap works in Java How HashMap works in Java or do you know Hashmap in java is one of the most asked interview question in java. It checks your knowledge about the collection as HashMap is one of the mostly used Collection class. Also I would like to mention another favorite interview question which is […]Continue Reading →
How to use TreeSet in Java : TreeSet in java is a class which implements Set interface. Let see few characteristics of TreeSet in java before taking look at java treeset example. TreeSet in java 1. TreeSet in java guarantees sorted set of elements which are arranged in ascending order. 2. TreeSet in java provides […]Continue Reading →
HashSet : HashSet implements Set interface. To store the values it uses Hashtable internally which uses hashing mechanism. Because of Hashing there are two advantages, first because it is used to find duplicates using the key and second is it gives constant time performance for operations such as add, remove, contains etc. Lets look at […]Continue Reading →
Lets see we can use which collections according to their characteristics : ArrayList : As ArraylList implements List interface. ArrayList allows random access and fast iteration. So ArrayList can be used when 1. We need random access to the element. 2. When we normally not required to remove the elements between the others as removing […]Continue Reading →
Lets see how we can increase the speed while processing the ArrayList. The default size for a Java ArrayList class at the initial stage is 10. When an ArrayList operation reaches its maximum capacity which is 10, it increases its capacity by approximately half. A lot of time gets consumed in this case. Lets see […]Continue Reading →
You may have following questions like : How to reverse the order of elements in java Vector ? How to reverse the order of elements in java ArrayList? You can easily reverse the order of elements in Vector and ArrayList using Collections class. java.util.Collections class contain lot of static methods which normally operates on collections […]Continue Reading →
Lets see what are the differences we can see in HashMap and Hashtable. 1. Synchronization : Hashtables are synchronized , it means at one point of time only one thread can modify a Hashtable. i.e any thread before performing an update on a hashtable will be acquiring a lock on the object while others will […]Continue Reading →
You must be having questions mentioned below: how to sort arraylist having objects? How to sort arraylist contianing the objects? Sorting an arraylist contianing the objects. Sorting an arraylist of objects. How to sort a custom made class using ArrayList? How to use Comparable Interface? How to sort objects in arraylist using compareTo? How to […]Continue Reading →
You may want to read it!
- Enum in java with java enum examples
- What is the difference between AWT and Swing in java
- How to set size of PDF file using iText?
- Simple JTable example using AbstractTableModel
- How to get Selected Items in JList Component?
- How to convert exponential format to Decimal number format in Java?
- How to make table fits the pdf page using iText?
- How to find LCM of two numbers - Java Example
- GridBagLayout tutorial and example
- Deadlock, starvation and livelock in context of Java