The List Interface in Java extends the Collection Interface and is a part of the java.util package. It is used to store the ordered collections of elements. In a Java List, we can organize and manage the data sequentially.
Key Features:
- Maintained the order of elements in which they are added.
- Allows duplicate elements.
- The implementation classes of the List interface are ArrayList, LinkedList, Stack, and Vector.
- It can add Null values that depend on the implementation.
- The List interface offers methods to access elements by their index and includes the listIterator() method, which returns a ListIterator.
- Using ListIterator, we can traverse the list in both forward and backward directions.
Example:
Java
// Java program to show the use of List Interface
import java.util.*;
class Geeks {
public static void main(String[] args)
{
// Creating a List of Strings using ArrayList
List<String> li = new ArrayList<>();
// Adding elements in List
li.add("Java");
li.add("Python");
li.add("DSA");
li.add("C++");
System.out.println("Elements of List are:");
// Iterating through the list
for (String s : li) {
System.out.println(s);
}
// Accessing elements
System.out.println("Element at Index 1: "+ li.get(1));
// Updating elements
li.set(1, "JavaScript");
System.out.println("Updated List: " + li);
// Removing elements
li.remove("C++");
System.out.println("List After Removing Element: " + li);
}
}
OutputElements of List are:
Java
Python
DSA
C++
Element at Index 1: Python
Updated List: [Java, JavaScript, DSA, C++]
List After Removing Element: [Java, JavaScript, DSA]
Declaration of Java List Interface
public interface List<E> extends Collection<E> ;
Lets get deep dive onto creating objects or instances in a List. List is an interface, objects cannot be created of the type list. We always need a class that implements this List in order to create an object. And also, after the introduction of Generics in Java 1.5, it is possible to restrict the type of object that can be stored in the List. Just like other user-defined "interfaces" implemented by user-defined "classes", List is an "interface", implemented by the ArrayList class, pre-defined in java.util package.
Syntax of List Interface
List<Obj> list = new ArrayList<Obj> ();
Obj is the type of the object to be stored in List.
The common implementation classes of the List interface are ArrayList, LinkedList, Stack, and Vector:
- ArrayList and LinkedList are the most widely used due to their dynamic resizing and efficient performance for specific operations.
- Stack is a subclass of Vector, designed for Last-In-First-Out (LIFO) operations.
- Vector is considered a legacy class and is rarely used in modern Java programming. It is replaced by ArrayList and java.util.concurrent package.
Now let us perform different operations using List Interface. We will be discussing the operations listed below and later on implementing them.
Java List - Operations
List can be used only with a class that implements this interface. Now, let's see how to perform a few frequently used operations on the List.
- Operation 1: Adding elements to List using add() method
- Operation 2: Updating elements in List using set() method
- Operation 3: Searching for elements using indexOf(), lastIndexOf methods
- Operation 4: Removing elements using remove() method
- Operation 5: Accessing Elements in List using get() method
- Operation 6: Checking if an element is present in the List using contains() method
Now, let us discuss the operations individually and implement the same in Java.
1. Adding Elements
To add an element to the list, we can use the add() method. This method is overloaded to perform multiple operations based on different parameters.
Parameters: It takes 2 parameters:
- add(Object o): This method is used to add an element at the end of the List.
- add(int index, Object o): This method is used to add an element at a specific index in the List
Note: If we do not specify the length of the array in the ArrayList constructor while creating the List object, using add(int index, Object) for any index i will throw an exception if we have not specified the values for 0 to i-1 index already.
Example:
Java
// Java Program to Add Elements to a List
import java.util.*;
class Geeks {
public static void main(String args[])
{
// Creating an object of List interface,
// implemented by ArrayList class
List<String> al = new ArrayList<>();
// Adding elements to object of List interface
// Custom elements
al.add("Geeks");
al.add("Geeks");
al.add(1, "For");
// Print all the elements inside the
// List interface object
System.out.println(al);
}
}
Output[Geeks, For, Geeks]
Note: If we try to add element at index 1 before adding elements at index 0 it will throw an error. It is always recommended to add elements in a particular index only when the size is defined or to add them sequentially.
2. Updating Elements
After adding the elements, if we want to change the element, it can be done using the set() method. Since List is indexed, the element which we wish to change is referenced by the index of the element. This method takes an index and the updated element which needs to be inserted at that index.
Example:
Java
// Java Program to Update Elements in a List
import java.util.*;
class Geeks {
public static void main(String args[])
{
// Creating an object of List interface
List<String> al = new ArrayList<>();
// Adding elements to object of List class
al.add("Geeks");
al.add("Geeks");
al.add(1, "Geeks");
// Display theinitial elements in List
System.out.println("Initial ArrayList " + al);
// Setting (updating) element at 1st index
// using set() method
al.set(1, "For");
// Print and display the updated List
System.out.println("Updated ArrayList " + al);
}
}
OutputInitial ArrayList [Geeks, Geeks, Geeks]
Updated ArrayList [Geeks, For, Geeks]
3. Searching Elements
Searching for elements in the List interface is a common operation in Java programming. The List interface provides several methods to search for elements, such as the indexOf(), lastIndexOf() methods.
Parameters:
- indexOf(Object o): It returns the index of the first occurrence of the specified element in the list, or -1 if the element is not found
- lastIndexOf(Object o): It returns the index of the last occurrence of the specified element in the list, or -1 if the element is not found
Example:
Java
// Java program to search the elements in a List
import java.util.*;
class Geeks {
public static void main(String[] args)
{
// create a list of integers
List<Integer> al = new ArrayList<>();
// add some integers to the list
al.add(1);
al.add(2);
al.add(3);
al.add(2);
// use indexOf() to find the first occurrence of an
// element in the list
int i = al.indexOf(2);
System.out.println("First Occurrence of 2 is at Index: "+i);
// use lastIndexOf() to find the last occurrence of
// an element in the list
int l = al.lastIndexOf(2);
System.out.println("Last Occurrence of 2 is at Index: "+l);
}
}
OutputFirst Occurrence of 2 is at Index: 1
Last Occurrence of 2 is at Index: 3
4. Removing Elements
To remove an element from a list, we can use the remove() method. This method is overloaded to perform multiple operations based on different parameters.
Parameters:
- remove(Object o): This method is used to simply remove an object from the List. If there are multiple such objects, then the first occurrence of the object is removed.
- remove(int index): This method takes an integer value which simply removes the element present at that specific index in the List. After removing the element, all the elements are moved to the left to fill the space and the indices of the objects are updated.
Example:
Java
// Java Program to Remove Elements from a List
import java.util.ArrayList;
import java.util.List;
class Geeks {
public static void main(String args[])
{
// Creating List class object
List<String> al = new ArrayList<>();
// Adding elements to the object
// Custom inputs
al.add("Geeks");
al.add("Geeks");
// Adding For at 1st indexes
al.add(1, "For");
// Print the initialArrayList
System.out.println("Initial ArrayList " + al);
// Now remove element from the above list
// present at 1st index
al.remove(1);
// Print the List after removal of element
System.out.println("After the Index Removal " + al);
// Now remove the current object from the updated
// List
al.remove("Geeks");
// Finally print the updated List now
System.out.println("After the Object Removal " + al);
}
}
OutputInitial ArrayList [Geeks, For, Geeks]
After the Index Removal [Geeks, Geeks]
After the Object Removal [Geeks]
5. Accessing Elements
To access an element in the list, we can use the get() method, which returns the element at the specified index.
Parameter: get(int index): This method returns the element at the specified index in the list.
Example:
Java
// Java Program to Access Elements of a List
import java.util.*;
class Geeks {
public static void main(String args[])
{
// Creating an object of List interface,
// implemented by ArrayList class
List<String> al = new ArrayList<>();
// Adding elements to object of List interface
al.add("Geeks");
al.add("For");
al.add("Geeks");
// Accessing elements using get() method
String first = al.get(0);
String second = al.get(1);
String third = al.get(2);
// Printing all the elements inside the
// List interface object
System.out.println(first);
System.out.println(second);
System.out.println(third);
System.out.println(al);
}
}
OutputGeeks
For
Geeks
[Geeks, For, Geeks]
6. Checking if an element is present or not
To check if an element is present in the list, we can use the contains() method. This method returns true if the specified element is present in the list, otherwise, it returns false.
Parameter: contains(Object o): This method takes a single parameter, the object to be checked if it is present in the list.
Example:
Java
// Java Program to Check if an Element is Present in a List
import java.util.*;
class Geeks {
public static void main(String args[])
{
// Creating an object of List interface,
// implemented by ArrayList class
List<String> al = new ArrayList<>();
// Adding elements to object of List interface
al.add("Geeks");
al.add("For");
al.add("Geeks");
// Checking if element is present using contains()
// method
boolean isPresent = al.contains("Geeks");
// Printing the result
System.out.println("Is Geeks present in the list? "+ isPresent);
}
}
OutputIs Geeks present in the list? true
Complexity of List Interface in Java
Operation | Time Complexity | Space Complexity |
---|
Adding Element in List Interface | O(1) | O(1) |
---|
Remove Element from List Interface | O(N) | O(N) |
---|
Replace Element in List Interface | O(N) | O(N) |
---|
Traversing List Interface | O(N) | O(N) |
---|
Iterating over List Interface in Java
Till now we are having a very small input size and we are doing operations manually for every entity. Now let us discuss various ways by which we can iterate over the list to get them working for a larger sample set.
Methods: There are multiple ways to iterate through the List. The most famous ways are by using the basic for loop in combination with a get() method to get the element at a specific index and the advanced for a loop.
Example:
Java
// Java program to Iterate the Elements
// in an List
import java.util.*;
public class Geeks {
public static void main(String args[])
{
// Creating an empty Arraylist of string type
List<String> al = new ArrayList<>();
// Adding elements to above object of ArrayList
al.add("Geeks");
al.add("Geeks");
// Adding element at specified position
// inside list object
al.add(1, "For");
// Using for loop for iteration
for (int i = 0; i < al.size(); i++) {
// Using get() method to
// access particular element
System.out.print(al.get(i) + " ");
}
// New line for better readability
System.out.println();
// Using for-each loop for iteration
for (String str : al)
// Printing all the elements
// which was inside object
System.out.print(str + " ");
}
}
OutputGeeks For Geeks
Geeks For Geeks
Methods of the List Interface
Methods | Description |
---|
add(int index, element) | This method is used with Java List Interface to add an element at a particular index in the list. When a single parameter is passed, it simply adds the element at the end of the list. |
addAll(int index, Collection collection) | This method is used with List Interface in Java to add all the elements in the given collection to the list. When a single parameter is passed, it adds all the elements of the given collection at the end of the list. |
size() | This method is used with Java List Interface to return the size of the list. |
clear() | This method is used to remove all the elements in the list. However, the reference of the list created is still stored. |
remove(int index) | This method removes an element from the specified index. It shifts subsequent elements(if any) to left and decreases their indexes by 1. |
remove(element) | This method is used with Java List Interface to remove the first occurrence of the given element in the list. |
get(int index) | This method returns elements at the specified index. |
set(int index, element) | This method replaces elements at a given index with the new element. This function returns the element which was just replaced by a new element. |
indexOf(element) | This method returns the first occurrence of the given element or -1 if the element is not present in the list. |
lastIndexOf(element) | This method returns the last occurrence of the given element or -1 if the element is not present in the list. |
equals(element) | This method is used with Java List Interface to compare the equality of the given element with the elements of the list. |
hashCode() | This method is used with List Interface in Java to return the hashcode value of the given list. |
isEmpty() | This method is used with Java List Interface to check if the list is empty or not. It returns true if the list is empty, else false. |
contains(element) | This method is used with List Interface in Java to check if the list contains the given element or not. It returns true if the list contains the element. |
containsAll(Collection collection) | This method is used with Java List Interface to check if the list contains all the collection of elements. |
sort(Comparator comp) | This method is used with List Interface in Java to sort the elements of the list on the basis of the given comparator. |
Java List vs Set
Both the List interface and the Set interface inherits the Collection interface. However, there exists some differences between them.
List | Set |
---|
The List is an ordered sequence. | The Set is an unordered sequence. |
List allows duplicate elements | Set doesn’t allow duplicate elements. |
Elements by their position can be accessed. | Position access to elements is not allowed. |
Multiple null elements can be stored. | The null element can store only once. |
List implementations are ArrayList, LinkedList, Vector, Stack | Set implementations are HashSet, LinkedHashSet. |
Classes Association with a Java List Interface
Now let us discuss the classes that implement the List Interface for which first do refer to the pictorial representation below to have a better understanding of the List interface. It is as follows:

AbstractList, CopyOnWriteArrayList, and the AbstractSequentialList are the classes that implement the List interface. A separate functionality is implemented in each of the mentioned classes. They are as follows:
- AbstractList: It is a skeletal implementation for the List interface but does not necessarily imply the list is unmodifiable. It is used for both mutable and immutable lists depending on the subclass implementation.
- CopyOnWriteArrayList: This class implements the list interface. It is an enhanced version of ArrayList in which all the modifications (add, set, remove, etc.) are implemented by making a fresh copy of the list.
- AbstractSequentialList: This class extends AbstractList. This class is used to provide the skeletal implementation for lists that are accessed sequiencially (i.e iterators) to create a concrete class. It can implement the get(int index) and size() methods.
We will proceed in this manner.
- ArrayList
- Vector
- Stack
- LinkedList
Let us discuss them sequentially and implement the same to figure out the working of the classes with the List interface.
1. ArrayList
An ArrayList class which is implemented in the collection framework provides us with dynamic arrays in Java. It may be slower than standard arrays but can be helpful in programs where lots of manipulation in the array is needed. Let's see how to create a list object using this class.
Example:
Java
// Java program to demonstrate the
// creation of list object using the
// ArrayList class
import java.io.*;
import java.util.*;
class Geeks {
public static void main(String[] args)
{
// Size of ArrayList
int n = 5;
// Declaring the List with initial size n
List<Integer> arrli = new ArrayList<Integer>(n);
// Appending the new elements
// at the end of the list
for (int i = 1; i <= n; i++)
arrli.add(i);
// Printing elements
System.out.println(arrli);
// Remove element at index 3
arrli.remove(3);
// Displaying the list after deletion
System.out.println(arrli);
// Printing elements one by one
for (int i = 0; i < arrli.size(); i++)
System.out.print(arrli.get(i) + " ");
}
}
Output[1, 2, 3, 4, 5]
[1, 2, 3, 5]
1 2 3 5
2. Vector
Vector is a class that is implemented in the collection framework implements a growable array of objects. Vector implements a dynamic array that means it can grow or shrink as required. Like an array, it contains components that can be accessed using an integer index. Let's see how to create a list object using this class.
Example:
Java
// Java program to demonstrate the
// creation of list object using the
// Vector class
import java.io.*;
import java.util.*;
class Geeks {
public static void main(String[] args)
{
// Size of the vector
int n = 5;
// Declaring the List with initial size n
List<Integer> v = new Vector<Integer>(n);
// Appending the new elements
// at the end of the list
for (int i = 1; i <= n; i++)
v.add(i);
// Printing elements
System.out.println(v);
// Remove element at index 3
v.remove(3);
// Displaying the list after deletion
System.out.println(v);
// Printing elements one by one
for (int i = 0; i < v.size(); i++)
System.out.print(v.get(i) + " ");
}
}
Output[1, 2, 3, 4, 5]
[1, 2, 3, 5]
1 2 3 5
3. Stack
Stack is a class that is implemented in the collection framework and extends the vector class models and implements the Stack data structure. The class is based on the basic principle of last-in-first-out (LIFO). With basic push and pop operations, the class provides three more functions of empty, search and peek. Let’s see how to create a list object using this class.
Example:
Java
// Java program to demonstrate the
// creation of list object using the
// Stack class
import java.io.*;
import java.util.*;
class Geeks {
public static void main(String[] args)
{
// Size of the stack
int n = 5;
// Declaring the List
List<Integer> s = new Stack<Integer>();
// Appending the new elements
// at the end of the list
for (int i = 1; i <= n; i++)
s.add(i);
// Printing elements
System.out.println(s);
// Remove element at index 3
s.remove(3);
// Displaying the list after deletion
System.out.println(s);
// Printing elements one by one
for (int i = 0; i < s.size(); i++)
System.out.print(s.get(i) + " ");
}
}
Output[1, 2, 3, 4, 5]
[1, 2, 3, 5]
1 2 3 5
4. LinkedList
LinkedList is a class that is implemented in the collection framework which inherently implements the linked list data structure. It is a linear data structure where the elements are not stored in contiguous locations and every element is a separate object with a data part and address part. Let’s see how to create a list object using this class.
Example:
Java
// Java program to demonstrate the
// creation of list object using the
// LinkedList class
import java.io.*;
import java.util.*;
class Geeks {
public static void main(String[] args)
{
// Size of the LinkedList
int n = 5;
// Declaring the List with initial size n
List<Integer> ll = new LinkedList<Integer>();
// Appending the new elements
// at the end of the list
for (int i = 1; i <= n; i++)
ll.add(i);
// Printing elements
System.out.println(ll);
// Remove element at index 3
ll.remove(3);
// Displaying the list after deletion
System.out.println(ll);
// Printing elements one by one
for (int i = 0; i < ll.size(); i++)
System.out.print(ll.get(i) + " ");
}
}
Output[1, 2, 3, 4, 5]
[1, 2, 3, 5]
1 2 3 5
ArrayList vs LinkedList
ArrayList | LinkedList |
---|
Underlying structure is Dynamic Array | Underlying structure is Doubly-linked list |
O(1) - Fast random access | O(n) - Slow random access |
Memory is lower (contiguous memory) | Memory is higher (extra pointers per node) |
Iteration speed is faster | Iterartion speed is slower. |
Insertion and deletion is slower | Insertion and deletion is faster. |
Similar Reads
Java Tutorial Java is a high-level, object-oriented programming language used to build web apps, mobile applications, and enterprise software systems. Known for its Write Once, Run Anywhere capability, which means code written in Java can run on any device that supports the Java Virtual Machine (JVM).Syntax and s
10 min read
Basics
Introduction to JavaJava is a high-level, object-oriented programming language developed by Sun Microsystems in 1995. It is platform-independent, which means we can write code once and run it anywhere using the Java Virtual Machine (JVM). Java is mostly used for building desktop applications, web applications, Android
4 min read
Java Programming BasicsJava is one of the most popular and widely used programming language and platform. A platform is an environment that helps to develop and run programs written in any programming language. Java is fast, reliable and secure. From desktop to web applications, scientific supercomputers to gaming console
4 min read
Java MethodsJava Methods are blocks of code that perform a specific task. A method allows us to reuse code, improving both efficiency and organization. All methods in Java must belong to a class. Methods are similar to functions and expose the behavior of objects.Example: Java program to demonstrate how to crea
7 min read
Access Modifiers in JavaIn Java, access modifiers are essential tools that define how the members of a class, like variables, methods, and even the class itself, can be accessed from other parts of our program. They are an important part of building secure and modular code when designing large applications. In this article
6 min read
Arrays in JavaIn Java, an array is an important linear data structure that allows us to store multiple values of the same type. Arrays in Java are objects, like all other objects in Java, arrays implicitly inherit from the java.lang.Object class. This allows you to invoke methods defined in Object (such as toStri
9 min read
Java StringsIn Java, a String is the type of object that can store a sequence of characters enclosed by double quotes and every character is stored in 16 bits, i.e., using UTF 16-bit encoding. A string acts the same as an array of characters. Java provides a robust and flexible API for handling strings, allowin
8 min read
Regular Expressions in JavaIn Java, Regular Expressions or Regex (in short) in Java is an API for defining String patterns that can be used for searching, manipulating, and editing a string in Java. Email validation and passwords are a few areas of strings where Regex is widely used to define the constraints. Regular Expressi
7 min read
OOPs & Interfaces
Classes and Objects in JavaIn Java, classes and objects are basic concepts of Object Oriented Programming (OOPs) that are used to represent real-world concepts and entities. A class is a template to create objects having similar properties and behavior, or in other words, we can say that a class is a blueprint for objects.An
10 min read
Java ConstructorsIn Java, constructors play an important role in object creation. A constructor is a special block of code that is called when an object is created. Its main job is to initialize the object, to set up its internal state, or to assign default values to its attributes. This process happens automaticall
10 min read
Java OOP(Object Oriented Programming) ConceptsBefore Object-Oriented Programming (OOPs), most programs used a procedural approach, where the focus was on writing step-by-step functions. This made it harder to manage and reuse code in large applications.To overcome these limitations, Object-Oriented Programming was introduced. Java is built arou
10 min read
Java PackagesPackages in Java are a mechanism that encapsulates a group of classes, sub-packages and interfaces. Packages are used for: Prevent naming conflicts by allowing classes with the same name to exist in different packages, like college.staff.cse.Employee and college.staff.ee.Employee.They make it easier
8 min read
Java InterfaceAn Interface in Java programming language is defined as an abstract type used to specify the behaviour of a class. An interface in Java is a blueprint of a behaviour. A Java interface contains static constants and abstract methods. Key Properties of Interface:The interface in Java is a mechanism to
11 min read
Collections
Exception Handling
Java Exception HandlingException handling in Java is an effective mechanism for managing runtime errors to ensure the application's regular flow is maintained. Some Common examples of exceptions include ClassNotFoundException, IOException, SQLException, RemoteException, etc. By handling these exceptions, Java enables deve
8 min read
Java Try Catch BlockA try-catch block in Java is a mechanism to handle exceptions. This make sure that the application continues to run even if an error occurs. The code inside the try block is executed, and if any exception occurs, it is then caught by the catch block.Example: Here, we are going to handle the Arithmet
4 min read
Java final, finally and finalizeIn Java, the keywords "final", "finally" and "finalize" have distinct roles. final enforces immutability and prevents changes to variables, methods, or classes. finally ensures a block of code runs after a try-catch, regardless of exceptions. finalize is a method used for cleanup before an object is
4 min read
Chained Exceptions in JavaChained Exceptions in Java allow associating one exception with another, i.e. one exception describes the cause of another exception. For example, consider a situation in which a method throws an ArithmeticException because of an attempt to divide by zero.But the root cause of the error was an I/O f
3 min read
Null Pointer Exception in JavaA NullPointerException in Java is a RuntimeException. It occurs when a program attempts to use an object reference that has the null value. In Java, "null" is a special value that can be assigned to object references to indicate the absence of a value.Reasons for Null Pointer ExceptionA NullPointerE
5 min read
Exception Handling with Method Overriding in JavaException handling with method overriding in Java refers to the rules and behavior that apply when a subclass overrides a method from its superclass and both methods involve exceptions. It ensures that the overridden method in the subclass does not declare broader or new checked exceptions than thos
4 min read
Java Advanced
Java Multithreading TutorialThreads are the backbone of multithreading. We are living in the real world which in itself is caught on the web surrounded by lots of applications. With the advancement in technologies, we cannot achieve the speed required to run them simultaneously unless we introduce the concept of multi-tasking
15+ min read
Synchronization in JavaIn multithreading, synchronization is important to make sure multiple threads safely work on shared resources. Without synchronization, data can become inconsistent or corrupted if multiple threads access and modify shared variables at the same time. In Java, it is a mechanism that ensures that only
10 min read
File Handling in JavaIn Java, with the help of File Class, we can work with files. This File Class is inside the java.io package. The File class can be used to create an object of the class and then specifying the name of the file.Why File Handling is Required?File Handling is an integral part of any programming languag
6 min read
Java Method ReferencesIn Java, a method is a collection of statements that perform some specific task and return the result to the caller. A method reference is the shorthand syntax for a lambda expression that contains just one method call. In general, one does not have to pass arguments to method references.Why Use Met
9 min read
Java 8 Stream TutorialJava 8 introduces Stream, which is a new abstract layer, and some new additional packages in Java 8 called java.util.stream. A Stream is a sequence of components that can be processed sequentially. These packages include classes, interfaces, and enum to allow functional-style operations on the eleme
15+ min read
Java NetworkingWhen computing devices such as laptops, desktops, servers, smartphones, and tablets and an eternally-expanding arrangement of IoT gadgets such as cameras, door locks, doorbells, refrigerators, audio/visual systems, thermostats, and various sensors are sharing information and data with each other is
15+ min read
JDBC TutorialJDBC stands for Java Database Connectivity. JDBC is a Java API or tool used in Java applications to interact with the database. It is a specification from Sun Microsystems that provides APIs for Java applications to communicate with different databases. Interfaces and Classes for JDBC API comes unde
12 min read
Java Memory ManagementJava memory management is the process by which the Java Virtual Machine (JVM) automatically handles the allocation and deallocation of memory. It uses a garbage collector to reclaim memory by removing unused objects, eliminating the need for manual memory managementJVM Memory StructureJVM defines va
4 min read
Garbage Collection in JavaGarbage collection in Java is an automatic memory management process that helps Java programs run efficiently. Java programs compile to bytecode that can be run on a Java Virtual Machine (JVM). When Java programs run on the JVM, objects in the heap are created, which is a portion of memory dedicated
7 min read
Memory Leaks in JavaIn programming, a memory leak happens when a program keeps using memory but does not give it back when it's done. It simply means the program slowly uses more and more memory, which can make things slow and even stop working. Working of Memory Management in JavaJava has automatic garbage collection,
3 min read
Practice Java
Java Interview Questions and AnswersJava is one of the most popular programming languages in the world, known for its versatility, portability, and wide range of applications. Java is the most used language in top companies such as Uber, Airbnb, Google, Netflix, Instagram, Spotify, Amazon, and many more because of its features and per
15+ min read
Java Programs - Java Programming ExamplesIn this article, we will learn and prepare for Interviews using Java Programming Examples. From basic Java programs like the Fibonacci series, Prime numbers, Factorial numbers, and Palindrome numbers to advanced Java programs.Java is one of the most popular programming languages today because of its
8 min read
Java Exercises - Basic to Advanced Java Practice Programs with SolutionsLooking for Java exercises to test your Java skills, then explore our topic-wise Java practice exercises? Here you will get 25 plus practice problems that help to upscale your Java skills. As we know Java is one of the most popular languages because of its robust and secure nature. But, programmers
7 min read
Java Quiz | Level Up Your Java SkillsThe best way to scale up your coding skills is by practicing the exercise. And if you are a Java programmer looking to test your Java skills and knowledge? Then, this Java quiz is designed to challenge your understanding of Java programming concepts and assess your excellence in the language. In thi
1 min read
Top 50 Java Project Ideas For Beginners and Advanced [Update 2025]Java is one of the most popular and versatile programming languages, known for its reliability, security, and platform independence. Developed by James Gosling in 1982, Java is widely used across industries like big data, mobile development, finance, and e-commerce.Building Java projects is an excel
15+ min read