Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ex6;
- public class excript {
- public static void main(String[] args) {
- int[] arrayInt = new int[10];
- arrayInt[0] = 10;
- arrayInt[1] = 20;
- arrayInt[2] = 30;
- arrayInt[3] = 30;
- arrayInt[4] = 10;
- arrayInt[5] = 15;
- arrayInt[6] = 25;
- arrayInt[7] = 90;
- arrayInt[8] = 5;
- arrayInt[9] = 3;
- int soma = arrayInt[0]+ arrayInt[1] + arrayInt[2];
- // somar todos os elementos de uma vez
- System.out.println("A soma Γ© do array 0, 1 e 2 Γ©: "+soma);
- int soma2 = 0;
- for(int i = 0; i <10 ; i++){
- soma2 += arrayInt[i];
- }
- System.out.println("A soma de todos elementos Γ©: "+soma2);
- }
- /* CΓ©sar N. */
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement