java出错:需要标识符
来源:百度知道 编辑:UC知道 时间:2024/05/27 14:46:56
代码:
import java.io.*;
public class SimpleCharInOut
{
public static void main(String args[])
{
char c;
System.out.print("Enter a character please:"); try{ c=(char)System.in.read();
}catch(IOException){}; system.out.print("You've entered characrer"+c);
}
}
出错第八行 需要标识符 1错误
不懂为什么
import java.io.*;
public class SimpleCharInOut
{
public static void main(String args[])
{
char c;
System.out.print("Enter a character please:"); try{ c=(char)System.in.read();
}catch(IOException){}; system.out.print("You've entered characrer"+c);
}
}
出错第八行 需要标识符 1错误
不懂为什么
把你上面的代码改成:
import java.io.*;
public class SimpleCharInOut
{
public static void main(String args[])
{
char c=' ';
System.out.print("Enter a character please:");
try {
c = (char) System.in.read();
} catch (IOException ex) {
}
System.out.print("You've entered characrer " + c);
}
}
有几个错误
1、char c;
需要初始化
2、catch(IOException)改为catch(IOException e)
3、system.out.print("You've entered characrer"+c);
第一个s大写
最后一句System大写
catch(IOException){}
应该是catch(IOException e){}
你要定义IOException的对象啊
如 catch(IOException e){};