// A compact source file is a whole class body: fields, methods, and nested types all sit at the top level. // Nothing here is imported. List, Map, TreeMap, Collectors and BigDecimal all live in java.base. String greeting = "hello"; int calls = 0; record Point(int x, int y) { double distance() { return Math.sqrt(x * x + y * y); } } String shout(String s) { calls++; return s.toUpperCase() + "!"; } void main() { List words = List.of("banana", "apple", "cherry"); Map lengths = new TreeMap<>(); for (String w : words) lengths.put(w, w.length()); IO.println(shout(greeting)); IO.println(words.stream().sorted().collect(Collectors.joining(", "))); IO.println(lengths); IO.println(new BigDecimal("1.10").add(BigDecimal.ONE)); IO.println(new Point(3, 4) + " is " + new Point(3, 4).distance() + " from the origin"); IO.println("calls so far: " + calls); }