SHARE
TWEET

Java sum using array

chiplu Nov 17th, 2019 95 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package dadaproject.company;
  2. import java.util.Scanner;
  3. public class Main {
  4.  
  5.     public static void main(String[] args) {
  6.  
  7.     int a[]={4,6,7,3,9,10,44,55,12};
  8.     sum(a);
  9.  
  10.     }
  11.     public static void sum(int []a)
  12.     {
  13.         int sum =0;
  14.         for(int i:a)
  15.         {
  16.             sum = sum+i;
  17.         }
  18.         System.out.print(sum);
  19.     }
  20. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top