Mengambil input pengguna dalam array di java menggunakan konstruktor
public class ScoresDemo {
public static void main(String[] args) {
double testScores[] = new double [5];
TestScores scores = new TestScores(testScores);
Scanner scan = new Scanner(System.in);
for(int i = 0; i < testScores.length; i++) {
System.out.println("Enter some test scores: ");
testScores[i] = scan.nextDouble();
}
System.out.println("The average of the test scores is " + scores.averageScores());
}
}
Obedient Okapi