Find the Average of Numbers in Java
import java.util.*; public class Test { public static void main(String[] args) { List<Integer> numbers = new ArrayList<>(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); System.out.println(numbers.stream().mapToInt(Integer::intValue).average().getAsDouble()); } } Output: 5.5 Here, we used the mapToInt(Integer::intValue) to convert the Stream<Integer> which is the result of the stream() method, to IntStream. import java.util.*; public class…
Read More Find the Average of Numbers in Java