Java Collections
- 06 December
Update Value of Key in HashMap in Java
In this article, we will look at How to Update the Value of a Key in HashMap in Java. We will look at different solutions to this problem in detail with working examples. It is recommended to learn about the concept of collections particularly HashMaps in Java and their working for a seamless understanding. Now, […]
- 29 November
Create Array of Linked Lists in Java
Introduction In this article, we will look at how to Create an Array of Linked Lists in Java. We will look at ways to create an Array of Linked Lists or a List of Linked Lists in detail with working examples. Let us first have a quick peek into the concept of Linked Lists in […]
- 20 September
Return ArrayList in Java
This article discusses cases of returning an ArrayList in Java from a method. An ArrayList in Java is a collection of elements of the same data type under a single variable name. In different cases, you can return an ArrayList from a method in Java. These cases are as given below. Returning ArrayList from a […]
- 17 September
Create List with One Element in Java
In this post, we will see how to create List with One Element in java.. Using Collections.singletonList() This is best way to create List with single element if you need an immutable List. [crayon-6766e9af33c77143334860/] Output [crayon-6766e9af33c7c411397563/] If you try to add element to the list, you will get exception [crayon-6766e9af33c87170636184/] [crayon-6766e9af33c88126664532/] Using Array.asList() method [ […]
- 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 […]
- 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 […]
- 25 January
Create ArrayList of Objects in Java
In this tutorial, we will learn how to create ArrayList of objects in Java. We will create a Book class with different properties and use it to create custom book objects when creating an ArrayList of objects. We will filter these book objects using certain criteria and add the book objects that meet the criteria […]
- 10 September
How to remove element from Arraylist in java while iterating
Introduction In this tutorial, you will learn how to remove element from Arraylist in java while iterating using different implementations provided by Java. It is necessary to understand the right way to remove items from a List because we might encounter errors in our programs if not done correctly. For example, If we try to […]
- 30 June
Print HashMap in Java
In this article, we will see how to print HashMap in java using different method. Print from the HashMap Reference This is the most basic and easiest method to print out HashMap in java. Pass the HashMap reference to the System.out.println, and the HashMap will output the key-value of the elements enclosed in curly brackets. […]
- 1
- 2
- 3
- …
- 6
- Nextkeyboard_arrow_right