I want to add a 5 elements using for loop
but after entering 1st element it gives error
Here is my code
I am excepting from user at run time using scanner class
import java.util.Scanner;
import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner si = new Scanner(System.in);
List <Integer> cl = new ArrayList<>();
List <String> al = new ArrayList<>();
System.out.print("nnEnter the number of elements : ");
int n=si.nextInt();
for (int i=0; i<n ; i++ ) {
System.out.print("nnEnter the name of the account user : ");
al.add(si.nextLine());
System.out.print("nnEnter the amount you want to deposit in your account : ");
cl.add(si.nextInt());
}
}
}