import javaslang.collection.List; import javaslang.Tuple; import javaslang.Tuple2; public class Main { public static void main(String[] args) { Tuple2<String, Integer> student1 = Tuple.of("Alice", 80); Tuple2<String, Integer> student2 = Tuple.of("Bob", 90); Tuple2<String, Integer> student3 = Tuple.of("Charlie", 75); List<Tuple2<String, Integer>> students = List.of(student1, student2, student3); double averageScore = students.map(Tuple2::_2).average().getOrElse(0.0); System.out.println("Average Score: " + averageScore); } }


上一篇:
下一篇:
切换中文