Pre-requisite: Linked List Data Structure Like arrays, Linked List is a linear data structure. Unlike arrays, linked list elements are not stored at the contiguous… Read More
Tag Archives: Java-List-Programs
As we know that the ArrayList is not synchronized, if multiple threads try to modify an ArrayList at the same time, then the final outcome… Read More
Assuming you have gone through LinkedList in java and know about linked list. This post contains different examples for reversing a linked list which are… Read More
Assuming you have gone through arraylist in java and know about arraylist. This post contains different examples for reversing an arraylist which are given below:1.… Read More
An Array is a collection of elements which can be of either primitive datatypes or objects. Arrays in Java are static in nature. ArrayLists, on… Read More
In this article, Lambda Expression with Collections is discussed with examples of sorting different collections like ArrayList, TreeSet, TreeMap, etc. Sorting Collections with Comparator (or… Read More
ImmutableList, as suggested by the name, is a type of List which is immutable. It means that the content of the List are fixed or… Read More
We have discussed that an array of ArrayList is not possible without warning. A better idea is to use ArrayList of ArrayList. // Java code… Read More
We often come across 2D arrays where most of the part in the array is empty. Since space is a huge problem, we try different… Read More
Shuffling a list Collections.shuffle() is used to shuffle lists in java.Class hierarchy: java ↳ util ↳ Collections Syntax: Collections.shuffle(list); Examples: Java // Java program to demonstrate… Read More
A Map is an object that maps keys to values or is a collection of attribute-value pairs. The list is an ordered collection of objects… Read More
Suppose we have an elements in ArrayList, we can count the occurrences of elements present in a number of ways. HashMap This data structure uses… Read More
We generally iterate through the list when adding integers in a range, but java.util.stream.Stream has a sum() method that when used with filter() gives the… Read More
Given a list (ArrayList or LinkedList), convert it into a set (HashSet or TreeSet) of strings in Java. Method 1 (Simple) We simply create an… Read More