java324.java

来自「项目实战」· Java 代码 · 共 32 行

JAVA
32
字号
class DepartmentException extends Exception{
	DepartmentException(){
		System.out.println("此部门不存在!!!");
	}
}
class EmployeeDetails{
	protected EmployeeDetails(){
	}
	public static void main(String[] a){
		int empId,deptId;
		String empName;
		String []args={"123","abc","2"};
		try{
			empId=Integer.parseInt(args[0]);
			empName=args[1];
			deptId=Integer.parseInt(args[1]);
			if(deptId>5){
				throw new DepartmentException();
			}else{
				System.out.println("雇员编号是:"+empId);
				System.out.println("雇员姓名是:"+empName);
				System.out.println("部门编号是:"+deptId);
			}
		}catch(DepartmentException de){
			System.out.println("数据无效");
		}catch(NumberFormatException ne){
			System.out.println("数据错误");
		}catch(ArrayIndexOutOfBoundsException ae){
			System.out.println("数据不完整");
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?