Friday, October 30, 2020

Differences between HashMap and HashTable in Java

HashMap and Hashtable store key/value pairs in a hash table. When using a Hashtable or HashMap, we specify an object that is used as a key, and the value that you want linked to that key. The key is then hashed, and the resulting hash code is used...

Wednesday, October 28, 2020

Comparator Interface in Java with Examples

Comparator interface is used to order the objects of user-defined classes. A comparator object is capable of comparing two objects of two different classes. Following function compare obj1 with obj2Syntax: public int compare(Object obj1, Object obj2):Suppose we have an array/arraylist of our own class type, containing fields like rollno,...

Tuesday, October 27, 2020

Scanner Class in Java

Scanner is a class in java.util package used for obtaining the input of the primitive types like int, double, etc. and strings. It is the easiest way to read input in a Java program, though not very efficient if you want an input method for scenarios where time...

Monday, October 26, 2020

Start a Java app without installing it

This article describes how you can use JShell to download and execute a Java application. It will eliminate the need for the installation of the application.Do not install, just run!The first obstacle that you have to overcome to make people use your app is the installation.You want people...

Sunday, October 25, 2020

Java String to String Array Conversion Examples

A quick and practical guide on how to convert String to String Array in different ways in java.1. OverviewIn this article, you’ll learn how to convert String to String Array in java with example programs.2.  Using the split() methodString api is added with split() method which takes the...

Friday, October 23, 2020

Java Program To Get Union Of Two Arrays

A quick and programming guide to how to get the union of two unsorted arrays in java with example programs.1. OverviewIn this article, you’ll learn how to get the union of two arrays in java. A union set is all the values of two sets or from all...

Wednesday, October 21, 2020

Locking for multiple nodes the easy way: GCS

It happens to all of us. We develop stateless applications that can scale horizontally without any effort.However sometimes cases arise where you need to achieve some type of coordination.You can go really advanced on this one. For example you can use a framework like Akka and it’s cluster...

Monday, October 19, 2020

Java Program to Calculate Average Using Arrays

1. OverviewIn this article, you’ll learn how to calculate the average of numbers using arrays. You should know the basic concepts of a java programming language such as Arrays and forEach loops.We’ll see the two programs on this. The first one is to iterate the arrays using for each...

Friday, October 16, 2020

Lifecycle and States of a Thread in Java

A thread in Java at any point of time exists in any one of the following states. A thread lies only in one of the shown states at any instant:1. New2. Runnable3. Blocked4. Waiting5. Timed Waiting6. TerminatedThe diagram shown below represent various states of a thread at any...

Pages (26)1234567 »