集册 Java实例教程 在方法的声明中使用throw子句

在方法的声明中使用throw子句

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

448
在方法的声明中使用throw子句

import java.io.IOException;


public class Main {
/**
N o w  J a v a  .   c o m 提供 
**/

  public static void main(String[] args) {  

    char c = '\u0000';

    try {

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

      c = readChar();

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

    } 

    catch(IOException e) {

      System.out.println("Error occurred while reading input.");

                }  

  }

  public static char readChar() throws IOException {

    char c = '\u0000';
    /**
     * nowjava 提 供 
    **/

    
展开阅读全文