// Created on savesnippets.com · https://savesnippets.com/0ghgU3zYnoHmsf import java.util.*; class Util { // PRODUCES T → use extends // Accepts List, List, etc — reads but cannot add public static double sum(List nums) { double total = 0; for (Number n : nums) total += n.doubleValue(); return total; } // CONSUMES T → use super // Accepts List, List, List — adds but cannot safely read public static void addInts(List sink) { sink.add(1); sink.add(2); sink.add(3); } public static void main(String[] args) { List ints = List.of(1, 2, 3); List dbls = List.of(1.5, 2.5); System.out.println(sum(ints)); // 6.0 System.out.println(sum(dbls)); // 4.0 List sink = new ArrayList<>(); addInts(sink); System.out.println(sink); // [1, 2, 3] } }