import java.util.*;
import java.io.*;
import java.lang.*;
class Ex
{
public static void main (String[] args) throws IOException
{
BufferedReader br = new BufferedReader(newInputStreamReader(System.in));
int a,b,n,c;
n=Integer.parseInt(br.readLine());
for(int i=1;i<=n;i++)
{
try
{
a=Integer.parseInt(br.readLine());
b=Integer.parseInt(br.readLine());
try
{
c=a/b;
System.out.println(c);
}
catch (ArithmeticException e)
{
System.out.println(e);
}
}
catch (InputMismatchException m)
{
System.out.println(m);
}
}
}
}
上面提到的是我试图运行的代码,下面是 input_file.txt
4
10
3
10
Hello
10
2
23.323
0.0
这是我得到的错误。
Exception in thread "main" java.lang.NumberFormatException: For input string: "4 "
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.parseInt(Integer.java:615)
at Ex.main(Ex.java:11)
慕码人8056858
陪伴而非守候
相关分类