In Java 8 and above you can create a List of Functional Interfaces to store the methods, as the following example shows:
// Create a list of Consumer
List<Consumer<String>> methodList= new ArrayList<>();
// Store the methods in the list
methodList.add(p -> method1(p));
methodList.add(p -> method2(p));
methodList.add(p -> method3(p));
methodList.forEach(f -> f.accept("Hello"));
Functions with no arguments you can use Runnable:
List<Runnable> methods = new ArrayList<>();
methods.add(() -> method1());
methods.add(() -> method2());
methods.add(() -> method3());
methods.forEach(f -> f.run());
Answer from Rodrigo Eggea on Stack OverflowOracle
docs.oracle.com › javase › 8 › docs › api › java › util › List.html
List (Java Platform SE 8 )
October 20, 2025 - The List interface provides four methods for positional (indexed) access to list elements. Lists (like Java arrays) are zero based. Note that these operations may execute in time proportional to the index value for some implementations (the LinkedList class, for example).
W3Schools
w3schools.com › java › java_list.asp
Java List
assert abstract boolean break byte case catch char class continue default do double else enum exports extends final finally float for if implements import instanceof int interface long module native new package private protected public return requires short static super switch synchronized this throw throws transient try var void volatile while Java String Methods
Videos
11:12
Java Collections Framework-Part 3: List Interface in Java Collection ...
10:17
Java Tutorial #47 - Java List Interface with Examples (Collections) ...
06:01
Java Tutorial - Working with LISTS - YouTube
13:17
How to Use Lists in Java - YouTube
12:15
ArrayList | Most Commonly Used Methods | Java Collections Framework ...
GeeksforGeeks
geeksforgeeks.org › java › list-interface-java-examples
List Interface in Java - GeeksforGeeks
This method is overloaded to perform multiple operations based on different parameters. remove(Object o): Removes the first occurrence of the specified object from the list. remove(int index): Removes the element at the specified index and shifts subsequent elements left. ... 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"); System.out.println("Initial ArrayList " + al); // Now remove element from the above list present at 1st index al.remove(1); System.out.println("After the Index Removal " + al); // Now remove the current object from the updated List al.remove("Geeks"); System.out.println("After the Object Removal " + al); } }
Published 1 month ago
Top answer 1 of 2
8
In Java 8 and above you can create a List of Functional Interfaces to store the methods, as the following example shows:
// Create a list of Consumer
List<Consumer<String>> methodList= new ArrayList<>();
// Store the methods in the list
methodList.add(p -> method1(p));
methodList.add(p -> method2(p));
methodList.add(p -> method3(p));
methodList.forEach(f -> f.accept("Hello"));
Functions with no arguments you can use Runnable:
List<Runnable> methods = new ArrayList<>();
methods.add(() -> method1());
methods.add(() -> method2());
methods.add(() -> method3());
methods.forEach(f -> f.run());
2 of 2
3
In Java, you can do this with reflection by making a list of Method objects. However, an easier way is to define an interface for objects that have a method that takes an Object argument:
public interface MethodRunner {
public void run(Object arg);
}
List<MethodRunner> a = new ArrayList<>();
a.add(new MethodRunner() {
@Override
public void run(Object arg) {
myCustomMethod1(arg);
}
});
a.add(new MethodRunner() {
@Override
public void run(Object arg) {
myCustomMethod2(arg);
}
});
Object o = new Object();
for (MethodRunner mr : a) {
mr.run(o);
}
YouTube
youtube.com › watch
Java Programming Tutorial 45 - Working with Lists (List Methods) - YouTube
Start your software dev career - https://calcur.tech/dev-fundamentals 💯 FREE Courses (100+ hours) - https://calcur.tech/all-in-ones🐍 Python Course - https:...
Published August 14, 2019
DigitalOcean
digitalocean.com › community › tutorials › java-list
Java List - List in Java | DigitalOcean
August 3, 2022 - Java List interface is a member of the Java Collections Framework. List allows you to add duplicate elements. List allows you to have ‘null’ elements. List interface got many default methods in Java 8, for example replaceAll, sort and spliterator.
Java Programming
java-programming.mooc.fi › part-3 › 2-lists
Lists - Java Programming
ArrayList is a pre-made tool in Java that helps dealing with lists. It offers various methods, including ones for adding values to the list, removing values from it, and also for the retrieval of a value from a specific place in the list.
Oracle
docs.oracle.com › en › java › javase › 21 › docs › api › java.base › java › util › List.html
List (Java SE 21 & JDK 21)
January 20, 2026 - The List interface provides four methods for positional (indexed) access to list elements. Lists (like Java arrays) are zero based. Note that these operations may execute in time proportional to the index value for some implementations (the LinkedList class, for example).
Programiz
programiz.com › java-programming › list
Java List Interface
Some of the commonly used methods of the Collection interface that's also available in the List interface are: ... import java.util.List; import java.util.ArrayList; class Main { public static void main(String[] args) { // Creating list using the ArrayList class List<Integer> numbers = new ArrayList<>(); // Add elements to the list numbers.add(1); numbers.add(2); numbers.add(3); System.out.println("List: " + numbers); // Access element from the list int number = numbers.get(2); System.out.println("Accessed Element: " + number); // Remove element from the list int removedNumber = numbers.remove(1); System.out.println("Removed Element: " + removedNumber); } }
iO Flood
ioflood.com › blog › java-list-methods
Java List Methods Explained: From Basics to Advanced
February 27, 2024 - In this example, we create a new ArrayList and add the string ‘Hello’ to it using the add() method. We then retrieve the first item in the list using the get() method, which returns ‘Hello’. This is just a basic introduction to Java List methods, but there’s much more to learn about ...
Tutorialspoint
tutorialspoint.com › home › java › java list interface
Java List Interface
September 1, 2008 - Java Vs. C++ ... The List interface extends Collection and declares the behavior of a collection that stores a sequence of elements. Elements can be inserted or accessed by their position in the list, using a zero-based index. A list may contain duplicate elements. In addition to the methods defined by Collection, List defines some of its own, which are summarized in the following table.
Medium
medium.com › @reetesh043 › java-collection-list-interface-7b8cc69f2a5a
Java Collection: List Interface. Introduction | by Reetesh Kumar | Medium
January 24, 2024 - Here’s a basic example using a LinkedList to illustrate the implementation and usage of its methods: import java.util.LinkedList; import java.util.List; public class Example { public static void main(String[] args) { // Create a list of Integers List<Integer> numbers = new LinkedList<>(); numbers.add(1); numbers.add(2); numbers.add(3); // Add an element to the list at index 1 numbers.add(1, 4); numbers.forEach(System.out::println); // prints 1 4 2 3 // Get the element at a specific index int number = numbers.get(0); System.out.println(number); // prints 1 // Check if the list contains a specific element boolean contains4 = numbers.contains(4); System.out.println(contains4); // prints true // Remove an element from the list int index = numbers.indexOf(3); numbers.remove(index); // Iterate over the list numbers.forEach(System.out::println); // prints 1 4 2 } }
GeeksforGeeks
geeksforgeeks.org › java › methods-in-java
Java Methods - GeeksforGeeks
It consists of the method name and a parameter list. ... Note: The return type and exceptions are not considered as part of it. ... In Java language method name is typically a single word that should be a verb in lowercase or a multi-word, that begins with a verb in lowercase followed by an ...
Published January 24, 2026
Naukri
naukri.com › code360 › library › java-list
List Interface in Java with Methods & Examples
Almost there... just a few more seconds