Error while entering input using bufferedreader in java

236 views Asked by At
import java.util.*;
import java.lang.*;
import java.io.*;

class GFG {
    public static void main (String[] args) throws  java.lang.Exception {
        //code
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer(br.readLine());
        int qu=Integer.parseInt(br.readLine());
        while(qu-- >0)
        {
            int n=Integer.parseInt(br.readLine());
            String[] s = br.readLine().trim().split("\\s+"); 
            int arr[]=new int[n];
            long prod=1;
            for(int i=0;i<n;i++)
             {arr[i]=Integer.parseInt(s[i]);
              prod*=arr[i];
             }
             for(int i=0;i<n;i++)
             {
                 System.out.print(prod/arr[i]+" ");
             }
            System.out.println();
            
            
        }
    }
}

This is my code and I want to give this as my input: (I am using \n to show "enter" key) 1 \n 5 \n 10 3 5 6 2

and I am getting this exception:

Runtime Error:

Runtime ErrorException in thread "main" java.lang.NumberFormatException: For input string: "10 3 5 6 2" at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) at java.base/java.lang.Integer.parseInt(Integer.java:652) at java.base/java.lang.Integer.parseInt(Integer.java:770) at GFG.main(File.java:15)

0

There are 0 answers