ͨ¹ýJava·´Éäµ÷Ó÷½·¨
ͨ¹ýJava·´Éäµ÷Ó÷½·¨
ÕâÊǸö²âÊÔÓõÄÀý×Ó£¬Í¨¹ý·´Éäµ÷ÓöÔÏóµÄ·½·¨¡£
TestRef.java
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
/**
* Created by IntelliJ IDEA.
* File: TestRef.java
* User: leizhimin
* Date: 2008-1-28 14:48:44
*/
public class TestRef {
public static void main(String args[]) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
Foo foo = new Foo("Õâ¸öÒ»¸öFoo¶ÔÏó£¡");
Class clazz = foo.getClass();
Method m1 = clazz.getDeclaredMethod("outInfo");
Method m2 = clazz.getDeclaredMethod("setMsg", String.class);
Method m3 = clazz.getDeclaredMethod("getMsg");
m1.invoke(foo);
m2.invoke(foo, "ÖØÐÂÉèÖÃmsgÐÅÏ¢£¡");
String msg = (String) m3.invoke(foo);
System.out.println(msg);
}
}
class Foo {
private String msg;
public Foo(String msg) {
this.msg = msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public String getMsg() {
return msg;
}
public void outInfo() {
System.out.println("ÕâÊDzâÊÔJava·´ÉäµÄ²âÊÔÀà");
}
}
¿ØÖÆ̨Êä³ö
Ïà¹ØÎĵµ£º
ÔÚ½ñÄê11Ô·ݣ¬ºêÌìÈí¼þ¿ª·ÅÁ˹«Ë¾µÄ¿ªÔ´°æOA 1.2
beta°æ±¾£¬µÃµ½Í¬ÐÐÒÔ¼°ÆóÒµµÄÈÈÁÒÏìÓ¦£¬¹«Ë¾Ò²¼Ó½ôÁËÏÂÒ»²½µÄ¿ªÔ´µÄ²½·¥£¬ºêÌìÈí¼þ°ÑÏÖÐеÄÆóÒµ°æ1.2.1Ò²¶ÔËùÓÐÆóÒµ¿ª·ÅÔ´´úÂ루ÔÝʱ²»¶Ô¸öÈË¿ª
·Å£¬ËäȻĿǰÓкܶà¸öÈ˼°Èí¼þ¿ª·¢ÊÒÇ¿ÁÒÒªÇ󣩣¬ÆóÒµÖ»ÐèÒª»¨ÉÏÍòÔª×óÓÒ£¬¾Í¿ÉÒÔ¹ºÂò¸Ã°æ±¾µÄÈ«²¿´úÂ룬²¢»ñµÃÊÚȨ»ùÓÚ´ËÏ ......
JAVA×Ö·û±àÂë
½ñÌìÖÕÓÚ°ÑJAVAÀïÒ»¸ö±È½ÏÍ·Í´µÄÎÊÌâ——×Ö·û±àÂëŪÇåÎúÁË£¬ËùÒÔдһƪÎÄÕÂÀ´¼ÍÄîһϣ¬Ò²Îª´ó¼ÒÌṩһµã×Ô¼ºµÄÐĵá£
ÖÚËùÖÜÖª£¬JAVAΪÁ˹ú¼ÊͨÓã¬ÓõÄÊÇUNICODEÀ´±£´æÀïÃæµÄ×Ö·û¡£¶øUNICODEÖ»ÊÇÒ»¸öÖÖ×Ö·û¼¯£¬×Ö·ûµÄ´æ´¢ºÍ±íʾҪÓõ½Ò»¶¨µÄ×Ö·û±àÂë¸ñʽ£¬¶øÓëUNICODE¶ÔÓ¦µÄ×Ö·û±àÂë¸ñʽ¾ÍÊÇÎÒ ......
StringÊDZȽÏÌØÊâµÄÊý¾ÝÀàÐÍ£¬Ëü²»ÊôÓÚ»ù±¾Êý¾ÝÀàÐÍ£¬µ«ÊÇ¿ÉÒÔºÍʹÓûù±¾Êý¾ÝÀàÐÍÒ»ÑùÖ±½Ó¸³Öµ£¬²»Ê¹ÓÃnew¹Ø¼ü×Ö½øÐÐʵÀý»¯¡£Ò²¿ÉÒÔÏñÆäËûÀàÐÍÒ»ÑùʹÓùؼü×Önew½øÐÐʵÀý»¯¡£ÏÂÃæµÄ´úÂ붼ÊǺϷ¨µÄ£º
String s1 = "this is a string!";
String s2 = new String("this is another string!");
Áí ......
WindowsÏÂJAVAÓõ½µÄ»·¾³±äÁ¿Ö÷ÒªÓÐ3¸ö£¬JAVA_HOME¡¢CLASSPATH¡¢PATH¡£
JAVA_HOMEÖ¸ÏòµÄÊÇJDKµÄ°²×°Â·¾¶£¬ÈçD:\JDK\jdk1.5.0_12£¬ÔÚÕâ·¾¶ÏÂÄãÓ¦¸ÃÄܹ»ÕÒµ½bin¡¢libµÈĿ¼¡£
JAVA_HOME=D:\JDK\jdk1.5.0_15
PATH»·¾³±äÁ¿ÔÀ´WindowsÀïÃæ¾ÍÓУ¬ÄãÖ»ÐèÐÞ¸Äһϣ¬Ê¹ËûÖ¸ÏòJDKµÄbinĿ¼£¬ÕâÑùÄãÔÚ¿ØÖÆ̨ÏÂÃæ±àÒë¡¢Ö´ÐгÌÐòʱ ......
Õ»Óë¶Ñ¶¼ÊÇJavaÓÃÀ´ÔÚRamÖдæ·ÅÊý¾ÝµÄµØ·½¡£ÓëC++²»Í¬£¬Java×Ô¶¯¹ÜÀíÕ»ºÍ¶Ñ£¬³ÌÐòÔ±²»ÄÜÖ±½ÓµØÉèÖÃÕ»»ò¶Ñ¡£
JavaµÄ¶ÑÊÇÒ»¸öÔËÐÐʱÊý¾ÝÇø,ÀàµÄ(¶ÔÏó´ÓÖзÖÅä¿Õ¼ä¡£ÕâЩ¶ÔÏóͨ¹ýnew¡¢newarray¡¢anewarrayºÍmultianewarrayµÈÖ¸ÁÁ¢£¬ËüÃDz»ÐèÒª³ÌÐò´úÂëÀ´ÏÔʽµÄÊÍ·Å¡£¶ÑÊÇÓÉÀ¬»ø»ØÊÕÀ´¸ºÔðµÄ£¬¶ÑµÄÓÅÊÆÊÇ¿ÉÒÔ¶¯Ì¬µØ·ÖÅäÄÚ´æ ......