Java Arrays and Methods Help! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Java Arrays and Methods Help!

Main() holds an array 10 integers. Create 2 methods that accept the array. 1st method named average returns the average from the 10 numbers while the second method named returns the greatest number from the list. !! Please help me, im stock at 1st method i can't call the variable in to the method

10th Mar 2017, 3:26 PM
Malvin Ravela
Malvin Ravela - avatar
2 Answers
+ 8
Pass your array named arr like this: int avrg = average(arr); Your method must be declared as following then: public static int average(int[] arr){ int avrg; // add code to calculate average value return avrg; }
10th Mar 2017, 4:18 PM
Tashi N
Tashi N - avatar
0
Thanks tashi 👍, I will code it later.
11th Mar 2017, 1:26 AM
Malvin Ravela
Malvin Ravela - avatar