Learn Java and Programming through articles, code examples, and tutorials for developers of all levels.
Difference between HashMap vs IdentityHashMap in Java? Example
How to use lsof command in Linux? Example Tutorial
How to Synchronize HashMap in Java? Collections.synchronizedMap() Example Tutorial
Difference between WeakHashMap , IdentityHashMap, and EnumMap in Java?
Java HashMap keySet() , entrySet and values() Example - Tutorial
What is static and instance Method in Java? Example Tutorial
How to use Lambda Expression and method reference in Java? Example Tutorial
Composite Design Pattern Example in Java and Object Oriented Programming
Hello guys, if you are wondering how to use Composite design pattern in Java then you are at the right place. Composite design pattern is another object oriented design pattern introduced by Gang of Four in there timeless classic book Design pattern : Elements of Reusable software. Composite pattern as name suggest is used to compose similar things together, like similar objects. It implements an interface and also contains other objects which implements the same interface, also known as containee. One of the best example of Composite pattern from Java standard library is Swing's container classes e.g. Panel, which not only are Components by themselves, but also contains other components like JButton, Label, JTable etc.
6 Advanced Comparator and Comparable Examples in Java 8
How to convert String to long in Java? Example
How to convert String to Double in Java and double to String with Example
How to Read User Input and Password in Java from command line? Console Example
How to replace characters and substring in Java? String.replace(), replaceAll() and replaceFirst() Example
5 Difference between Hashtable vs HashMap in Java? Answer
Hashtable and HashMap are two hash-based collections in Java and are used to store objects as key-value pairs. Despite being hash-based and similar in functionality there is a significant difference between Hashtable and HashMap and without understanding those differences if you use Hashtable in place of HashMap then you may run into series of subtle programs which is hard to find and debug. Unlike the Difference between ArrayList and HashMap, Differences between Hashtable and HashMap are more subtle because both are similar kinds of collections. Before seeing the difference between HashMap and Hashtable let's see some common things between HashMap and Hashtable in Java.