Sum of 2 arrays problem

what’s wrong with my code;0--------------------

import java.util.;
public class Main {
public static void main(String args[]) {
Scanner cin = new Scanner(System.in);
int n1 = cin.nextInt(), arr1[] = new int[n1],count = 1;
for(int i = 0; i < n1; i++){
arr1[i] = cin.nextInt();
}
int n2 = cin.nextInt(), arr2[] = new int[n2],res[] = new int[n1
n2];
for(int i = 0; i < n2; i++){
arr2[i] = cin.nextInt();
}
int r1,m;
if(n1>n2){
r1 = n1-n2;
m = n1;
}else{
r1 = n2-n1;
m = n2;
}
for(int i = r1 ; i < m; i++){
res[i] = arr1[i]+arr2[i];
}
if(n1>n2){
for(int i = 0; i<r1;i++){
res[i] = arr1[i];}
}else{
for(int i = 0; i<r1;i++){
res[i] = arr2[i];}
}
for(int i = 0;i<res.length;i++){
if(count == n1*n2){
System.out.print(res[i]+","+" “+“END”);
}else{
System.out.print(res[i]+”,"+" ");
count++;
}
}
cin.close();
}
}

Your logic is not correct. You have to add the arrays considering that each array represents a number. You have just added corresponding elements of each array. Check the sample input given with the question.

  1. When we perform addition, we start adding from the last digits onwards. Like for 123 + 4567, you’ll add 3+7 first.
  2. You have not considered carryover anywhere.