map = new HashMap<>(); ..."> map = new HashMap<>(); ...">

YouTip LogoYouTip

Java Collections Framework

Collections Framework

import java.util.*;

List<String> list = new ArrayList<>();
list.add("Alice");
list.add("Bob");

Map<String, Integer> map = new HashMap<>();
map.put("Alice", 25);

Set<Integer> set = new HashSet<>();

Iteration

for (String item : list) { System.out.println(item); }
list.stream().filter(s -> s.startsWith("A")).forEach(System.out::println);

Summary

  • ArrayList, HashMap, HashSet are the most used collections
  • Streams provide functional-style operations
← C Programming Tutorial - HelloJava OOP - Classes and Objects β†’