Java Programming Tutorial - 29 - Summing Elements of Arrays

package apples;

public class boy {
public static void main (String []args) {
int thileban[]= {21,16,14,23,26,34};
int sum=0;
for(int counter = 0; counter<thileban.length;counter++) {
sum+=thileban[counter];
}
System.out.println("The sum of these numbers is " +sum);
}
}

Comments