import java.io.*;//調用io包
public class SimpleCharInOut
{
public static void main(String args[])
{
char ch=' ';//定義個字符ch初始為‘ ’
System.out.println(" Enter a character please");//在屏幕上輸出Enter a character please
try {//你要監視的程式碼放在 try 區塊里即可。在 try 區塊之后緊接著在 catch 子句里指定你希望捕捉的例外型態
ch=(char)System.in.read();//將從鍵盤輸入的字符賦給ch
}
catch(IOException e) //如果上面的代碼有錯誤,這里就捕獲
{ } ;//錯誤后不進行操作
System.out.println("You're entered character:" + ch);// 在屏幕上輸出You're entered character:
//和ch的值
}
}
1.讀萬卷書
2.行千里路
3.閱人無數