Advertisement
thenewboston

Java Programming Tutorial - 29 - Summing Elements of Arrays

Aug 22nd, 2014
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.28 KB | None | 0 0
  1. class apples{
  2.    public static void main(String[] args){
  3.       int bucky[]={21,16,86,21,3};
  4.       int sum=0;
  5.  
  6.       for(int counter=0;counter<bucky.length;counter++){
  7.          sum+=bucky[counter];
  8.       }
  9.  
  10.       System.out.println("The sum of theze numbers is " +sum);
  11.    }
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement