MCA
COLLECTIONS FRAMEWORK // ENTERPRISE CODE // ABSTRACT FACTORY // COLLECTIONS FRAMEWORK // ENTERPRISE CODE // ABSTRACT FACTORY //
BACK TO SYLLABUS
MEDIUM

COLLECTIONS FRAMEWORK

List, Set, Map, and collection utilities

CONCEPTS

01List Interface (ArrayList, LinkedList)
02Set Interface (HashSet, TreeSet)
03Map Interface (HashMap, TreeMap)
04Iterators and enhanced for loops
05Collections utility class
06Comparable and Comparator

SYNTAX_DEMO

Managing groups of objects
import java.util.*;

public class Main {
    public static void main(String[] args) {
        // List
        List<String> list = new ArrayList<>();
        list.add("Apple");
        list.add("Banana");
        
        // Map
        Map<String, Integer> map = new HashMap<>();
        map.put("Alice", 25);
        map.put("Bob", 30);
        
        for (Map.Entry<String, Integer> entry : map.entrySet()) {
            System.out.println(entry.getKey() + " is " + entry.getValue());
        }
    }
}