I understand the philosophy of use of the website is to ask complex/original questions yet as a beginner I cannot grasp where my code is incorrect and would love some help.
The objective of the code below is to merely sum an array of integers, yet eclipse keeps telling me to insert ; I would greatly appreciate any help with this. Many thanks in advance.
class SumArray {
public static void main(String args[]) {
int [] x ={1,2,3,4};
Sum(x);
}
public static void Sum(int [] a) {
int counter=0;
for(int i=0; i<a.length; i++){
counter+=a[i];
}
System.out.println(counter);
}
Aucun commentaire:
Enregistrer un commentaire