Java Programming Tutorial - Summing Elements of Arrays




import java.util.Random;

public class Coffee{

public static void main(String arg[]) { 
int thileban[] = { 21, 16, 86, 21, 3};
int sum = 0;

for(int counter = 0; counter<thileban.length; counter++) {
sum+=thileban[counter]; 
}
System.out.println("The sum of theze numbers is " +sum);

}


}


Comments