BeginnersBook.in

Programming For Geeks

  • Home
  • All Tutorials
    • Learn C
    • Learn Python
  • Programs
    • Java Programs
    • C++ Programs
    • C Programs
  • Algorithms
    • Sorting
  • MCQ’s
    • MySQL
    • Operating System
  • WordPress
    • Genesis Pro Themes
    • Blogs
  • Tools
    • Direct Download Link Generator
    • HTML Compiler
  • How to
    • Web Examples
  • Write For Us

Java Program to sum the element of an Array

October 14, 2018 By Mr. Robot

In this program, you will learn to find the sum of all elements of an array in Java. This program calculating the addition of all the numbers which are initialized.

1
2
3
4
5
6
7
8
9
10
11
12
public class SumofArray {
  public static void main(String[] args)
  {
    int sum=0;
    int a[] = {1,2,3,4,5,6,7,8,9,10};
    for(int i=0;i<=a.length;i++)
    {
      sum = sum + i;
    }
      System.out.println("Sum of Array Elements: "+sum);
  }
}
When you run above program, the output will be following:
1
Sum of Array Elements: 55

Filed Under: Java examples

Related Posts

  • Java Program to Find middle index where sum of both ends are equal in an Array
  • Java Program to Convert Hexadecimal Number to Decimal
  • Java Program to Add Two Matrix Using Multi-dimensional Arrays

Recent Posts

  • Download Grand Theft Auto: Vice City Audio File | Highly Compressed
  • Grand Theft Auto: Vice City Game Download For PC | Full Setup
  • SQL SHOW DATABASES Statement
  • Direct view storage Tube (DVST) in Computer Graphics
  • CRT Color Monitor in Computer Graphics

Java Examples

  • More 300+ Java Programs
  • Hello, World
  • Add Two Numbers
  • Area of Triangle
  • Arithmetic Operation
  • Palindrome String
  • Upper or LowerCase
  • Leap Year
  • Toggle String
  • Automorphic Number
  • Neon Number
  • Strong Number
  • Spy Number

Pattern Examples

  • Simple (*) Pattern Programs
  • Tricky (*) Pattern Programs
  • Wave Pattern Programs

More…

  • C++ Programs
  • C Programs

Copyright © 2019 - BeginnersBook.in - All Right Reserved || Sitemap