SyntaxFix
Write A Post
Hire A Developer
Questions
The Java 8 streaming api offers an elegant alternative:
public static void main(String[] args) { double avg = Arrays.stream(new int[]{1,3,2,5,8}).average().getAsDouble(); System.out.println("avg: " + avg); }