Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

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;
 }
}


Ïà¹ØÎĵµ£º

java±£ÁôÁ½Î»Ð¡Êý

/**
   * ±£ÁôÁ½Î»Ð¡Êý
   * @param d
   * @return
   */
  private static double remainTwoNumbers(double d){
    java.math.BigDecimal   f1   =   new   java.math.BigDecimal(d);//СÊýµãºó±£Áô2Î ......

JAVA·´Éä»úÖÆÊÂÀýÒ»

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 ......

ÓÃjavaץȡcnproxy´úÀí·þÎñÆ÷µØÖ·

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 ......

Java Reflection dzÎö1

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 ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ