Java Collections Framework: Lists, Sets & Maps

8 min read JAVA 6 views

The Java Collections Framework

The Collections Framework provides prebuilt, highly optimized data structures including ArrayList, LinkedList, HashSet, and HashMap.

java Example
Run Code
import java.util.*;

public class CollectionsDemo {
    public static void main(String[] args) {
        List<String> students = new ArrayList<>();
        students.add("Shyam");
        students.add("Rahul");

        Map<String, Integer> scores = new HashMap<>();
        scores.put("Shyam", 98);
        scores.put("Rahul", 92);

        for (String s : students) {
            System.out.println(s + " scored: " + scores.get(s));
        }
    }
}

Related Tutorials