嗨当我运行下面的代码我得到NumberFormatException
任何人都可以帮助我在调试代码。这段代码有什么问题?
import java.io.*;
public class Case1 {
public static void main(String args[])
{
char ch='y';int i=0;
BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
System.out.println("ch before while:::"+ch);
while(ch=='y'||ch=='Y'){
try{
System.out.println("Enter the option");
i=Integer.parseInt(bf.readLine());
System.out.println("after"+i);
switch {
case 1 ystem.out.println("1"); break;
case 2 ystem.out.println("1"); break;
}
System.out.println("do u want to continue(Y/y");
ch=(char)bf.read();
System.out.println("ch after execution:::"+ch);
}
catch(NumberFormatException e){e.printStackTrace();}
catch(IOException e){e.printStackTrace();}
}
}}
首先,请格式化您的代码。其次,异常发生在哪条线上? – Bobby 2010-09-28 09:28:19
如果代码不能编译,IDE(Eclipse,Netbeans,IntelliJ IDEA等)应该解释代码中出现哪些错误以及原因。 – 2010-09-28 09:34:09
检查此链接http://forums.sun.com/thread.jspa?forumID=54&threadID=762831 – Emil 2010-09-28 10:08:09