集册 Java实例教程 从主方法引发异常

从主方法引发异常

欢马劈雪     最近更新时间:2020-01-02 10:19:05

510
从主方法引发异常

import java.io.IOException;
//N  o w  J a v a . c o m

public class Main {

  public static void main(String[] args) throws IOException {

    char c = '\u0000';

    System.out.print("Enter some text and then press Enter key: ");

    c = readChar();

    System.out.print("The first character you entered is: " + c);

  }

  public static char readChar() throws IOException {

    char c = '\u0000';

    int input = 0;

    input = System.in.read();

    
展开阅读全文