package a;
import java.util.*;
public class YiChang {

    public static void main(String[] args) {
        System.out.println("输入整数:");
        try 
        {
            Scanner a=new Scanner(System.in);
            int b=a.nextInt();
        
        }
        catch (Exception e)
        {
            e.printStackTrace();
            System.out.println("输入有误!"+e.getMessage());
        }
        
        
        
    }

}

要求用户输入数字,捕获并处理用户输入错误的异常,给用户进行提示

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-30
  • 2021-12-06
  • 2021-07-27
  • 2021-05-20
猜你喜欢
  • 2022-12-23
  • 2021-11-11
  • 2021-08-09
  • 2022-02-26
  • 2021-11-16
  • 2022-12-23
相关资源
相似解决方案