public class getchar { public static void main(String[] args) throws java.io.IOException //必不可少 { int num = System.in.read(); //讀進來的數,默認保存為整數,如果需要輸出 剛才輸入字符,需要用char進行強制轉換(type cast) char c = (char) num; System.out.println("the char you've just input is: " + c + "\nits unicode number is: " + num); } }
