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;
}
}
Ïà¹ØÎĵµ£º
/**
* ±£ÁôÁ½Î»Ð¡Êý
* @param d
* @return
*/
private static double remainTwoNumbers(double d){
java.math.BigDecimal f1 = new java.math.BigDecimal(d);//СÊýµãºó±£Áô2Î ......
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 ......
Reflection µÄ¼òµ¥Ó¦Ó㬰üÀ¨field£¬ method£¬constructorµÄÓ¦Óá£
package com.gaoqian.reflection;
import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.Typ ......