首页 > 编程语言 > 详细

Java学习之自定义异常

时间:2016-01-10 07:01:24      阅读:188      评论:0      收藏:0      [点我收藏+]

1
package com.gh; 2 import java.util.Scanner; 3 /** 4 * 自定义异常 5 * @author ganhang 6 * 7 */ 8 public class ExceptionDemo { 9 public static void main(String[] args) throws exception { 10 Scanner sc = new Scanner(System.in); 11 System.out.println("请输入帐号aaa密码123"); 12 String id = sc.nextLine(); 13 int pwd = sc.nextInt(); 14 if (!id.equals("aaa") || pwd != 123) 15 throw new exception("帐号或密码错误!"); 16 else System.out.println("帐号正确!"); 17 } 18 } 19 class exception extends Exception{ 20 public exception(String mes){ 21 super(mes); 22 } 23 }

 太久写的,知识点都没记,慢慢上传吧

Java学习之自定义异常

原文:http://www.cnblogs.com/ganhang-acm/p/5117704.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!