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

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

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
try {
Class cls = com.lwf.util.CommonUtil.class;
Object obj = cls.newInstance();
Method addMethod = cls.getMethod("add", new Class[]{int.class,int.class});
Object value = addMethod.invoke(obj, new Object[]{new Integer(12),new Integer(23)});
System.out.println((Integer)value);
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
package com.lwf.util;
public class CommonUtil {
public static void getName(){
System.out.println("this is a getName function");
}

public void getMethod(){
System.out.println("this is a getMethod funciton");
}

public int add(int m ,int n){
return m + n;

}
}


Ïà¹ØÎĵµ£º

ÔÚ Eclipse ÖÐÉèÖà java ÐéÄâ»úÄÚ´æµÄ·½·¨

        ÔÚʵ¼ÊµÄ¿ª·¢ÖУ¬ jvm ĬÈϵÄÄÚ´æ´óСÊDz»¹»µÄ£¬ÐèÒª×Ô¶¨ÒåÉèÖ᣿ɰ´ÈçÏµķ½·¨½øÐÐÉèÖãº
        µÚÒ»¡¢½øÈëµ½Ö¸¶¨ÔËÐÐÎļþµÄ run configurations, ¾Í»áµ¯³öÔËÐÐÉèÖöԻ°´°Ìå
        µÚ¶þ¡¢ÔÚ ja ......

java³£ÓÃʵÓÃÀàѧϰ11.29

ÏÖÔÚ ËùÓÃJava°æ±¾,DateÀ๹Ôì·½·¨Date(0)µÄʱ¼ä²»ÊÇThu Jan 01 01:00:00 GMT 1970ÁË£¬¶øÊÇThu Jan 01 08:00:00 CST 1970¡££¨ 1970 Äê1 ÔÂ1 ÈÕ8ʱ0·Ö0Ãë ÐÇÆÚ4£©
     Ϊʲô Date b1=new Date(623289600000); ²»¿ÉÒÔ£¬ÏÂÃæµÄÈ´¿ÉÒÔÄØ£¿
long a=623289600000L;
   Date b1=new Date(a); Ò ......

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

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

javaÈÕÆÚת»»

/**
  * ´¦Àíʱ¼äÒì³£ Date to String
  * Èç¹ûת»»³öÏÖÒì³£»á¸øÄ¬ÈÏÖµ00:00
  * @param time
  * @param sdf
  * @return
  */
 public static  String handleDateParseException(Object time){
  String tempTime = "00:00";
  try{
   ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ