• + 2 comments

    import java.io.; import java.util.;

    public class Solution {

    public static void main(String[] args) {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
        Scanner sc= new Scanner(System.in);
        List <Integer> first=new <Integer>ArrayList();
        int n=sc.nextInt();
        for(int i=0;i<n;i++){
            int m=sc.nextInt();
            first.add(m);
        }
        int q=sc.nextInt();
        for(int i=0;i<q;i++){
            String value=sc.nextLine();
    
            if(value.equals("Insert")){
            int x=sc.nextInt();
            int y=sc.nextInt();
                first.add(x,y);
            }
    
              else{
                int k=sc.nextInt();
                first.remove(k);
            }
        }
        for(Integer z:first)
            System.out.print(z+" ");
    }
    

    } ques------why I am getting input mismatch exception?

    Exception in thread "main" java.util.InputMismatchException at java.util.Scanner.throwFor(Scanner.java:864) at java.util.Scanner.next(Scanner.java:1485) at java.util.Scanner.nextInt(Scanner.java:2117) at java.util.Scanner.nextInt(Scanner.java:2076) at Solution.main(Solution.java:26)