import java.util.ArrayList;
import java.util.*;
public class Solution {
public static void main (String args []){
ArrayList<String> cars=new ArrayList<String>();
Scanner sc =new Scanner (System.in);
System.out.println(" enter the size of the list ");
int size=sc.nextInt();
for( int i =0;i<size;i++){
cars.add(i,sc.nextLine());
}
System.out.println(cars);
sc.close();
}
}
This program should output
1,2,3,4
But if I enter the size as 4 and I enter these values only but instead, if I write the size as 4 ... it doesn't take 4 arguments from me instead it will take three and print(' ',1,2,3)
please help