Monday, December 31, 2018

Difference between Hashmap and Hashtable?
  • HashMap is non-synchronized. Hashtable is synchronized. 
  • HashMap allows multiple threads where as hashtable doesn't
  • HashMap is not thread-safe where as hashtable is.
  • HashMap allows one null key and any number of null values. Hashtable doesn’t allow null keys and null values.
Note: We can make the HashMap as synchronized by calling this code
Map m = Collections.synchronizedMap(hashMap) [or] can be used ConcurrentHashMap for thread safe. HashMap throws ConcurrentModificationException when if other thread try to add/modify the contents of Object

Related Posts:

  • Extract numeric value from a String                    package seleniumrepo;                           public class ExtractNumerics{  … Read More
  • Anagram program in java package seleniumrepo; import java.util.Arrays; /*  * Check whether two strings are anagram of each other  * Ex: LISTEN <=> SILENT, TRIANGLE <=> INTEGRAL, HEART <=> EARTH  */ public cl… Read More
  • Lambda Expressions in Java Lambda Expressions: It is a anonymous(nameless) function. It does not has method name, method return type nor modifiers            General Method:            … Read More
  • Prime number a. prime or not Prime number: A prime number is a whole number greater than 1 whose only factors are 1 and itself. Ans: --- public class PrimeTest { public static void main(String[] args) { int n, i, k=0… Read More
  • Functional Interface in java Functional Interface: is an interface it contains only one abstract method and declares with annotation @FunctionalInterface E.g:                         @Func… Read More

0 comments:

Post a Comment

Selenium Training in Realtime

Blog helps to a student or IT employee to develop or improve skills in Software Testing.

Followers

About Me

My photo
Hyderabad, Andhra Pradesh, India
I am Automation Testing Professional. I have completed my graduation in B.Tech (Computers) from JNTU Hyderabad and started my career in Software Testing accidentally since then, I passionate on learning new technologies

Contact Form

Name

Email *

Message *

Popular Posts