Skip to content

Tag Archives: java-list

The clear() method of ArrayList in Java is used to remove all the elements from a list. The list will be empty after this call… Read More
ArrayList contains() method in Java is used for checking if the specified element exists in the given list or not. Syntax: public boolean contains(Object) object-element… Read More
The trimToSize() method of ArrayList in Java trims the capacity of an ArrayList instance to be the list’s current size. This method is used to… Read More
The isEmpty() method of ArrayList in java is used to check if a list is empty or not. It returns true if the list contains… 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
The lastIndexOf() method of ArrayList in Java is used to get the index of the last occurrence of an element in an ArrayList object. Syntax… Read More
The removeRange() method of ArrayList in Java is used to remove all elements within the specified range from an ArrayList object. It shifts any succeeding… 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
Given a set (HashSet or TreeSet) of strings in Java, convert it into a list (ArrayList or LinkedList) of strings. In java, Set interface is… Read More
CopyOnWriteArrayList class is introduced in JDK 1.5, which implements the List interface. It is an enhanced version of ArrayList in which all modifications (add, set,… Read More
Before proceeding further let us quickly revise the concept of the arrays and ArrayList quickly. So in java, we have seen arrays are linear data… Read More
Following methods can be used for converting Array To ArrayList:    Method 1: Using Arrays.asList() method   Syntax: public static List asList(T... a) // Returns… Read More
ArrayList and Vectors both implement the List interface, and both use (dynamically resizable) arrays for their internal data structure, much like using an ordinary array. … Read More
java.util.Collections.swap() method is a java.util.Collections class method. It swaps elements at the specified positions in given list. // Swaps elements at positions "i" and "j"… Read More
ArrayList is a part of collection framework and is present in java.util package. It provides us with dynamic arrays in Java. Though, it may be… Read More

Start Your Coding Journey Now!