Home Whiteboard Practice Code Graphing Calculator Online Compilers Articles Tools

Explore Categories

Find the perfect tutorial for your learning journey

Python TechnologiesDatabasesComputer ProgrammingWeb DevelopmentJava TechnologiesComputer ScienceMobile DevelopmentBig Data & AnalyticsMicrosoft TechnologiesDevOpsLatest TechnologiesMachine LearningDigital MarketingSoftware QualityManagement Tutorials View All Categories
Tutorials Courses Jobs Login
Technical Questions and Answers

Article Categories

  • All Categories
  • Data Structure Data Structure
  • Networking Networking
  • RDBMS RDBMS
  • Operating System Operating System
  • Java Java
  • MS Excel MS Excel
  • iOS iOS
  • HTML HTML
  • CSS CSS
  • Android Android
  • Python Python
  • C Programming C Programming
  • C++ C++
  • C# C#
  • MongoDB MongoDB
  • MySQL MySQL
  • Javascript Javascript
  • PHP PHP
  • Economics & Finance Economics & Finance
Selected Reading
  • UPSC IAS Exams Notes
  • Developer's Best Practices
  • Questions and Answers
  • Online Resume Builder
  • HR Interview Questions
  • Computer Glossary
  • Who is Who

How do you find the sum of all the numbers in a java array

Java Object Oriented Programming Programming

Following program print the sum of the all the numbers in an array.

Example

public class Tester {
   public static void main(String[] args) {
      int[] dataArray = {1, 2, 3, 4};
      int sum = 0;
      for(int i: dataArray) {
         sum += i;
      }
      System.out.println(sum);
   }
}

Output

10
Arushi
Arushi

Updated on: 2020-02-24T10:38:11+05:30

252 Views

Learn More in Our Tutorials

  • How to print summation of numbers in Java Javaexamples
  • Program to calculate sum of array in C Learn C By Examples
  • How to use for and foreach loops to display elements of an array using Java Javaexamples
  • How to sort an array and search an element inside it using Java Javaexamples
  • How to sort an array and search an element inside it using Java Javaexamples
Kickstart Your Career

Get certified by completing the course

Get Started
Previous Next
Advertisements
  • ABOUT US
  • OUR TEAM
  • CAREERS
  • JOBS
  • CONTACT US
  • TERMS OF USE
  • PRIVACY POLICY
  • REFUND POLICY
  • COOKIES POLICY
  • FAQ'S
tutorials point logo
Download Android App Download IOS App

Tutorials Point is a leading Ed Tech company striving to provide the best learning material on technical and non-technical subjects.

Copyright 2026. All Rights Reserved.