Problem sum of 2 arrays

import java.util.*;
public class Main {
public static void main (String args[]) {
Scanner cin = new Scanner(System.in);
int n = cin.nextInt(), m = cin.nextInt(), a[] = new int[n], b[] = new int[m];

   for(int i = 0;i<a.length;i++){
	   a[i] = cin.nextInt();
   }
   for(int i = 0;i<b.length;i++){
	   b[i] = cin.nextInt();
   }
  int s1 = a[0], s2 = b[0];
    for(int i = 1;i<a.length;i++){
	   s1 = s1*10 +a[i];
   }
      for(int i = 1;i<b.length;i++){
	   s2 = s2*10 +b[i];
   }
   System.out.println(s1);
    System.out.println(s2);

   int s = s1 + s2;
   ArrayList<Integer> al = new ArrayList<Integer>();
   while(s>0){
	   int d = s % 10;
	   al.add(d);
	   s = s / 10;
   }
Collections.reverse(al);
   for(int i: al){
	   System.out.print(i+", ");
   }
   System.out.print("END");
}

}====What’s the error;

You are taking input n& m first, then the arrays.Whereas it takes n ,then array, then m,then the array.

Please mark your doubt as resolved if you are satisfied and you can give ratings too based on my response :slight_smile: