Using List Interface in Java


The List interface is used to create ordered collections that can contain duplicate elements.

Source Code

import java.util.ArrayList;
import java.util.List;

public class TestList {
    public static void main(String[] args) {
        List list = new ArrayList();
        list.add("Hello");
        list.add("World");
        System.out.println(list.get(0)); // Access elements
    }
}
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments