Q:

summing 2 arrays to third array

i'm trying to make a program for my college task. it's about summing 2 arrays and the output into third array. but there's an error ArrayOutOfBoundsException but idk where's the error.
here's my source code  
Scanner sc = new Scanner(System.in);
    int[] arr1 = new int[3]; 
    int[] arr2 = new int[3]; 
    int i, j, k;
    for(i = 0; i < 3; i++) {
        System.out.print("Masukkan array pertama ke-" + i + ": ");
        arr1[i] = sc.nextInt();
    }

    for(j = 0; j < 3; j++) {
        System.out.print("Masukkan array kedua ke-" + j + ": ");
        arr2[j] = sc.nextInt();
    }

    for(k = 0; k < 4; k++) {
        int[] arr3 = new int[3];
        System.out.println(arr3[k] = arr1[i] + arr2[j]);
    }

the expected is like this 
arr1 = {1, 2, 3, 4}  
arr2 = {1, 2, 3, 4} 
arr3 = {2, 4, 6, 8}

A:

for(k = 0; k < 4; k++) {
        int[] arr3 = new int[3];
        System.out.println(arr3[k] = arr1[i] + arr2[j]);
    }

two major mistakes here. You do k < 4, while you should do k < 3
Also, you shouldn't re-create the array each iteration. Try this:
int[] arr3 = new int[3];
for(k = 0; k < 3; k++) {
        arr3[k] = arr1[k] + arr2[k]; // i and j don't make sense here.
    }

Printing the arrays, you can do after this.

