当前位置: 技术问答>java相关
请问下面这段程序哪里错了,如何修改,谢谢
来源: 互联网 发布时间:2015-07-25
本文导语: 本人初学java,请各位大侠多多赐教. import java.io.*; import java.awt.*; import java.lang.*; class char1{ public static void main(String args[]){ String buffer; BufferedReader my_in = new BufferedReader(new InputStreamRe...
本人初学java,请各位大侠多多赐教.
import java.io.*;
import java.awt.*;
import java.lang.*;
class char1{
public static void main(String args[]){
String buffer;
BufferedReader my_in
= new BufferedReader(new InputStreamReader(System.in));
do{
System.out.print("Enter a command:");
System.out.flush();
buffer = my_in.readLine();
}while(!buffer.equals("exit"));
}
}
import java.io.*;
import java.awt.*;
import java.lang.*;
class char1{
public static void main(String args[]){
String buffer;
BufferedReader my_in
= new BufferedReader(new InputStreamReader(System.in));
do{
System.out.print("Enter a command:");
System.out.flush();
buffer = my_in.readLine();
}while(!buffer.equals("exit"));
}
}
|
buffer = my_in.readLine();
这里要扑捉ioException
try{
do{
System.out.print("Enter a command:");
System.out.flush();
buffer = my_in.readLine();
}while(!buffer.equals("exit"));
}catch(Exception e){}
类名要和你的文件名一样,区别大小写。
另外好要设定:
环境变量path,和classpath
path=jdk安装目录bin
classpath=.;jdk安装目录lib
这里要扑捉ioException
try{
do{
System.out.print("Enter a command:");
System.out.flush();
buffer = my_in.readLine();
}while(!buffer.equals("exit"));
}catch(Exception e){}
类名要和你的文件名一样,区别大小写。
另外好要设定:
环境变量path,和classpath
path=jdk安装目录bin
classpath=.;jdk安装目录lib
|
try{
}
catch(IOException e){}加入异常处理吧!
}
catch(IOException e){}加入异常处理吧!