I want to take input from the console firstly, an integer and then an array of integer separated by comma and space.
The input is as follows:
5
55, 24, 32, 22, 89
and my code is:
public static void main (String[] args) {
//code
Scanner sc = new Scanner(System.in);
int num = sc.nextInt();
int[] array = new int[num];
String line = sc.nextLine();
line = line.replaceAll(" ","");
String[] temp = line.split(",");
for(String i :temp)
{
System.out.print(i+" ");
}
}
but it is showing InputMismatchException.