EDIT: Ive written code for the average, but i dont know how to make it so that it also uses ints from my args.length rather than the array
I need to
It seems old thread, but Java has evolved since then & introduced Streams & Lambdas in Java 8. So might help everyone who want to do it using Java 8 features.
Arrays.stream() . Once you have stream of String array elements, you can use mapToDouble(s -> Double.parseDouble(s)) which will convert stream of Strings into stream of doubles.Stream.collect(supplier, accumulator, combiner) to calculate average if you want to control incremental calculation yourselves. Here is some good example.Collectors.averagingDouble() which directly calculates and returns average. some examples here.