Preview:
package com.javacodegeeks.snippets.basics;

public class SumArrayWithForLoop {
	
	public static void main(String[] args) {
		
		// array to sum
		int[] numbers = new int[]{ 10, 10, 10, 10};
		 
		int sum = 0;
		 
		for (int i=0; i < numbers.length ; i++) {
			sum = sum + numbers[i];
		}
		 
		System.out.println("Sum value of array elements is : " + sum);
		
	}

}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter