• 17 May

    How to Add Multiple Values for Single Key In HashMap in Java

    This article discusses the HashMap in Java and how to add multiple values for Single Key In HashMap in Java. HashMap The HashMap in Java is an instrument that allows efficient access, insertion, deletion, and updating using the indexing concept by storing data in the form of key and value pairs. It was introduced in […]

  • 17 May

    How to Initialize an Array with 0 in Java

    This article discusses the arrays and different ways to initialize an array with 0 in Java. Arrays The arrays are the fundamental data structures, they are sequences of elements stored in contiguous memory locations. The first step when using a data structure involves initializing the data structure which in our case is arrays. Array instantiation […]

  • Set an array to another array in java
    23 April

    Set an Array Equal to Another Array in Java

    This article discusses methods to set an array equal to another array in Java. Arrays are the most basic data structures that store the data at contiguous memory locations. The operations on the array elements are performed using the indices. Setting an Array Variable Equal to Another Array Variable It might seem logical to set […]

  • Check if Object is null Java
    14 March

    Check if Object Is Null in Java

    An object in Java is an instance of a class. It is a real entity existing in the memory opposite to the class that acts as a blueprint for the object. The object represents data and methods for a particular entity that are defined by the class. In this article, you will learn to check […]

  • Java random number between 1 and 100
    07 March

    Generate Random Number Between 1 and 100 in Java

    Oftentimes, as a Java programmer, you might need to generate random numbers in a particular range. Java provides several inbuilt libraries to perform this task. There are third-party libraries as well to generate the random numbers. This article discusses the following methods to generate random number between 1 and 100. Random class of Java Utility […]

  • Check if array is empty in Java
    04 March

    Check if Array Is Empty in Java

    In this post, we will see how to check if array is empty in Java. The arrays are a data structure that facilitates storing multiple instances of data together in contiguous memory locations. This article discusses different cases when an array is considered to be empty in Java. It also discusses methods to check, for […]

  • java.lang.ClassCastException: java.util.Arrays$ArrayList cannot be cast to java.util.ArrayList
    22 February

    [Fixed] java.lang.ClassCastException: java.util.Arrays$ArrayList cannot be cast to java.util.ArrayList

    In this post, we will see how to fix java.lang.ClassCastException: java.util.Arrays$ArrayList cannot be cast to java.util.ArrayList. ClassCastException is runtime exception which indicate that code has tried to cast an object to a subclass which is not an instance. Reason for java.lang.ClassCastException: java.util.Arrays$ArrayList cannot be cast to java.util.ArrayList Although static method Arrays.asList() returns List, it returns […]

  • HashMap values cannot be cast to list
    21 February

    [Fixed] java.util.HashMap$Values cannot be cast to class java.util.List

    In this post, we will see how to fix error java.util.HashMap$Values cannot be cast to class java.util.List. Why HashMap values cannot be cast to list? HashMap values returns java.util.Collection and you can not cast Collection to List or ArrayList. It will throw ClassCastException in this scenario. Let’s understand with the help of example: [crayon-62b90ffa7d885270487122/] Output: […]

  • Format number with Commas in Java
    20 February

    Format Number with Commas in Java

    In this post, we will see how to format number with commas in java. How To Add Commas to Number in Java There are multiple ways to format number with commas in java. Let’s go through them. 1. Using DecimalFormat DecimalFormat can be used by providing formatting Pattern to format number with commas in java. […]