How to check if Key or Value exists in a Map ?

How to check if Key or Value exists in a Map ?

In this tutorial we will see how to check if Key or Value exists in a Map. Map or HashMap is the java collection class which stores data in Key-Value pair. Java collections is a set of classes and interfaces that implement commonly reusable collection data structures. To check if Key or Value exists in a Map, Map or …

Read More

How to generate pseudorandom numbers in Java ?

How to generate pseudorandom numbers in Java ?

In this post we will see how to generate pseudorandom numbers in Java. Before that we will see what is Random numbers. Random numbers are the numbers that occur in sequence such that the values are uniformly distributed over a defined interval or set, which is impossible to predict future values based on present and …

Read More

What is the difference between HashTable and HashMap in Java?

What is the difference between HashTable and HashMap in Java?

Both HashTable and HashMap are java collections and implements java.util.Map interface. Difference between HashTable and HashMap is the most common interview question. Many of the candidates who face the interview struggle to answer this question. Difference between HashTable and HashMap in Java Thread Safe: HashTable is thread-safe and can be shared between multiple threads but …

Read More

How to Sort a Map by key in Java?

How to Sort a Map by key in Java?

Here we will see how to sort a Map by key in java. There are two ways to sort a Map by Key –   First Approach Second Approach

Read More

How to use Preferences API to store application/Program configurations ?

How to use Preferences API to store application/Program configurations ?

Introduction Preferences (Java.util.pref) API is included in JDK can be used to remember and retrieve application preferences. Using this API you can manage preference data such as storing, retrieving, removing and cleaning preference data. This API is not intended to save application data. Also it reduces the burden of application developer to write the code …

Read More

How to convert Array to List in java?

How to convert Array to List in java?

Below code example show how to convert an array to List in java. To convert array based data into list, we can use java.util.Arrays class. This class provide a static method asList(Object[] a) that converts array into list. OUTPUT: TOM JACK JILL JANE

Read More

How to convert an array into a collection object?

How to convert an array into a collection object?

Below java code example show how to convert an array into a Collection object. To convert array based data into list / collection, we can use java.util.Arrays class. This class provide a static method asList(Object[] a) that converts array into list / collection. OUTPUT: TOM JACK JILL JANE

Read More