在使用jcreat4中,出现了问题,求解(我是新手)
源代码如下:
public class TestWhile
{
public static void main(String[] args)
{
// TODO code application logic here
int data;
int sum=0;
//Read an initial
System.out.println( "Enter an int value ");
data=MyInput.readInt();
//keep reading data until the input is 0
while(data!=0)
{
sum+=data;
System.out.println( "Enter an int value,the program exits if the input is 0 ");
data=MyInput.readInt();
}
System.out.println( "The sum is "+sum);
}
}
请问为什么在jcreat por4下运行会出现如下的错误:
Enter an int value
45
Exception in thread "main "
java.lang.NumberFormatException: For input string: "Enter an int value "
at java.lang.
NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:447)
at java.lang.Integer.parseInt(Integer.java:497)
at MyInput.readInt(MyInput.java:31)
at TestWhile.main(TestWhile.java:29)
Process completed.
------解决方案--------------------类型转换错误
------解决方案--------------------MyInput.readInt(); 是什么啊