As the header says, I was tipped by some people that if I wanted to print the sum of everything in an array of numbers, I should use the above-mentioned parameter for a for-loop (code will follow if further explanation is needed). But what is the exact definiton of what that does? The :-part I mean. Is it; for every number i in the array tall?
import java.util.*;
class Uke36{
public static void main(String[]args){
Scanner input=new Scanner(System.in);
int[] tall=new int[5];
for (int i=0; i<=4; i++){
System.out.println("Vennligst oppgi det " + (i+1) + ". tallet: ");
tall[i]=input.nextInt();
}
int sum = 0;
for(int i : tall){
sum+=;
}
}
}