Loading workspace environment...
Master ArrayList, HashMap, HashSet, Lambda expressions, and declarative Stream API pipelines (filter, map, reduce, collect).
List<String> list = new ArrayList<>(); list.add("Item");Dynamic list container.list.stream().filter(s -> s.length() > 3).toList();Declarative stream transformation.import java.util.*;
import java.util.stream.Collectors;
public class StreamDemo {
public static void main(String[] args) {
List<String> rawTech = List.of("Java", "TypeScript", "C++", "Python", "Go", "JavaScript", "Rust");
// Filter tech with > 4 characters, convert to uppercase, and sort
List<String> filteredTech = rawTech.stream()
.filter(t -> t.length() > 4)
.map(String::toUpperCase)
.sorted()
.collect(Collectors.toList());
System.out.println("Filtered Languages (>4 chars): " + filteredTech);
// Map word lengths to frequency grouping
Map<Integer, Long> lengthDistribution = rawTech.stream()
.collect(Collectors.groupingBy(String::length, Collectors.counting()));
System.out.println("Length Distribution: " + lengthDistribution);
}
}Filtered Languages (>4 chars): [JAVASCRIPT, PYTHON, TYPESCRIPT]
Length Distribution: {2=1, 3=1, 4=2, 6=1, 10=2}Stream<String> s = list.stream(); s.forEach(...); s.count(); // IllegalStateException: stream has already been operated uponList<String> filtered = list.stream().filter(...).toList(); long count = filtered.size();Architectural Explanation: Java Streams cannot be reused after a terminal operation has executed. Generate a new stream if another pass is needed.
Given a list of transaction prices, use the Stream API to filter transactions greater than $50, apply a 10% tax, and calculate the total sum.