Aishwarya Naglot has Published 180 Articles

Java program to detect loop in a LinkedList

Aishwarya Naglot

Aishwarya Naglot

Updated on 18-Jun-2025 12:20:51

469 Views

What is a LinkedList? A Linked list is a sequence of data structures where each node contains two parts as follows - Data: The value or information stored in the node. Next: A reference (or pointer) to the next node in the sequence. ... Read More

Java program to iterate over a Set

Aishwarya Naglot

Aishwarya Naglot

Updated on 17-Jun-2025 19:37:28

2K+ Views

A Set is a Collection that cannot contain duplicate elements. It models the mathematical set abstraction. The Set interface contains only methods inherited from Collection and adds the restriction that duplicate elements are prohibited. In this example, we will see how to iterate over a Set in Java using the ... Read More

Java program to remove duplicate elements from ArrayList

Aishwarya Naglot

Aishwarya Naglot

Updated on 17-Jun-2025 19:36:33

3K+ Views

ArrayList class in Java is a part of the Java Collections Framework and is used for storing a dynamically sized collection of elements. It is similar to an array, but it can grow and shrink in size according to the requirements of the program.Removing Duplicate Elements from an ArrayList ... Read More

How do I insert elements at a specific index in Java list?

Aishwarya Naglot

Aishwarya Naglot

Updated on 17-Jun-2025 19:31:42

682 Views

In this article, we will learn how to insert an element at a specific index in a Java list. For example, we have a fruit list by certain order and we want to insert a new fruit at a specific index in the list. Following are the ways to insert ... Read More

How do I insert all elements from one list into another in Java?

Aishwarya Naglot

Aishwarya Naglot

Updated on 13-Jun-2025 12:45:47

7K+ Views

In this article, we will learn how to insert all elements from one list into another in Java. This is a general operation we perform when working with lists while solving problems in Java. We will cover the following methods to insert all elements from one list into another: ... Read More

Can we insert null values in a Java list?

Aishwarya Naglot

Aishwarya Naglot

Updated on 13-Jun-2025 12:42:48

16K+ Views

Yes, we can insert null values into a list easily using its add() method. In case of List implementation does not support null, then it will thrown a NullPointerException List is an interface in Java that extends the Collection interface and provides a way to store an ordered collection of elements. ... Read More

How to find the last occurrence of an element in a Java List?

Aishwarya Naglot

Aishwarya Naglot

Updated on 10-Jun-2025 15:43:14

4K+ Views

In this article, we will learn how to find the last occurrence of an element in a Java List. It is a collection in which we can store and access elements in serial order. We can use the following ways to find the last occurrence of an element in a ... Read More

How to determine if all elements are the same in a Java List?

Aishwarya Naglot

Aishwarya Naglot

Updated on 10-Jun-2025 15:38:07

2K+ Views

In this article, we will explore how to determine if all elements in a Java List are the same. The following are the ways to achieve this: Using a For Loop Using Stream API Using a For Loop We will ... Read More

How do I remove multiple elements from a list in Java?

Aishwarya Naglot

Aishwarya Naglot

Updated on 10-Jun-2025 15:35:38

5K+ Views

A List extends a collection that is used to store elements in a sequential manner. Let's learn how to remove multiple elements from a list in Java. The following are a few ways to do that: Using a for Loop Using removeAll() ... Read More

Java program to convert a list to an array

Aishwarya Naglot

Aishwarya Naglot

Updated on 10-Jun-2025 15:21:51

19K+ Views

A List is a collection in Java that is used to store a sequence of elements. It is part of the Java Collections Framework and allows us to perform various operations on the elements, such as adding, removing, and accessing them. Converting a list to an array in Java can ... Read More

Previous 1 ... 6 7 8 9 10 ... 18 Next
Advertisements