Java SE 异常
package demo;
class TestA{
public int devide(int x,int y) throws ArithmeticException , DevideByMinusException{
if(y<0)
throw new DevideByMinusException("被除数为负",y);
int result=x/y;
return result;
}
}
public class TestException {
/**
* @param args
*/
public static void main(String[] args) {
// TODO 自动生成方法存根
try{
// int result=new TestA().devide(3,0);
int result=new TestA().devide(3,-1);
System.out.println(result);
}catch(ArithmeticException e){
System.out.println("in >>ArithmeticException<< ");
System.out.println(e.getMessage());
// e.printStackTrace();
}catch(DevideByMinusException e){
System.out.println("in >>DevideByMinusException<< ");
System.out.println(e.getMessage());
// e.printStackTrace();
}
System.out.println("program is running here,that is normal!");
}
}
class DevideByMinusException extends Exception{
int devisor;
public DevideByMinusException(String msg,int devisor){
super(msg);
this.devisor=devisor;
}
public int getDevisor(){
return devisor;
}
}
相关文档:
报文鉴别在身份认证中占重要位置,是认证系统的一个重要环节,在金融和商业系统中广泛应用。
报文鉴别常用报文鉴别码(Message Authentication Code,即MAC)作为鉴别的基础,
......
import java.lang.reflect.*;
public class ReflectTester {
public Object copy(Object object) throws Exception{
//获得对象的类型
Class classType=object.getClass();
System.out.println("Class:"+classType.getName());
//通过默认构造方法创建一个新的对象
Object objectCo ......
package org.mingyuan.fetcher;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.ArrayList;
i ......
1.servlet产生验证码:
package com.servlet;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Random;
import javax.imageio.ImageIO; ......
下面开讲故事:
从前有个房间,房间里有份文档,房间还有一把钥匙。 这把钥匙在张三手里。
这时李四来向张三要那份文档。 张三不太喜欢李四,但又怕耽误了
工作不好交代。于是张三就把房间里文档的文档复印了一份,然后把那个复印件交给了李四(这叫传值)。
李四拿到文档后(复印件),胡乱修改一 ......