Java·´Éä»úÖÆÉîÈëÑо¿
Java ·´ÉäÊÇJavaÓïÑÔµÄÒ»¸öºÜÖØÒªµÄÌØÕ÷£¬ËüʹµÃJava¾ßÌåÁË“¶¯Ì¬ÐÔ”¡£
ÔÚJavaÔËÐÐʱ»·¾³ÖУ¬¶ÔÓÚÈÎÒâÒ»¸öÀ࣬ÄÜ·ñÖªµÀÕâ¸öÀàÓÐÄÄЩÊôÐԺͷ½·¨£¿¶ÔÓÚÈÎÒâÒ»¸ö¶ÔÏó£¬ÄÜ·ñµ÷ÓÃËüµÄÈÎÒâÒ»¸ö·½·¨£¿´ð°¸Êǿ϶¨µÄ¡£ÕâÖÖ¶¯Ì¬»ñÈ¡ÀàµÄÐÅÏ¢ÒÔ¼°¶¯Ì¬µ÷ÓöÔÏóµÄ·½·¨µÄ¹¦ÄÜÀ´×ÔÓÚJava ÓïÑԵķ´É䣨Reflection£©»úÖÆ¡£
Java ·´Éä»úÖÆÖ÷ÒªÌṩÁËÒÔϹ¦ÄÜ£º
ÔÚÔËÐÐʱÅжÏÈÎÒâÒ»¸ö¶ÔÏóËùÊôµÄÀà¡£
ÔÚÔËÐÐʱ¹¹ÔìÈÎÒâÒ»¸öÀàµÄ¶ÔÏó¡£
ÔÚÔËÐÐʱÅжÏÈÎÒâÒ»¸öÀàËù¾ßÓеijÉÔ±±äÁ¿ºÍ·½·¨¡£
ÔÚÔËÐÐʱµ÷ÓÃÈÎÒâÒ»¸ö¶ÔÏóµÄ·½·¨¡£
Reflection ÊÇJava±»ÊÓΪ¶¯Ì¬£¨»ò×¼¶¯Ì¬£©ÓïÑÔµÄÒ»¸ö¹Ø¼üÐÔÖÊ¡£Õâ¸ö»úÖÆÔÊÐí³ÌÐòÔÚÔËÐÐʱ͸¹ýReflection APIsÈ¡µÃÈκÎÒ»¸öÒÑÖªÃû³ÆµÄclassµÄÄÚ²¿ÐÅÏ¢£¬°üÀ¨Æämodifiers£¨ÖîÈçpublic, static µÈµÈ£©¡¢superclass£¨ÀýÈçObject£©¡¢ÊµÏÖÖ®interfaces£¨ÀýÈçSerializable£©£¬Ò²°üÀ¨fieldsºÍmethods µÄËùÓÐÐÅÏ¢£¬²¢¿ÉÓÚÔËÐÐʱ¸Ä±äfieldsÄÚÈÝ»òµ÷ÓÃmethods¡£
Ò»°ã¶øÑÔ£¬¿ª·¢ÕßÉçȺ˵µ½¶¯Ì¬ÓïÑÔ£¬´óÖÂÈÏͬµÄÒ»¸ö¶¨ÒåÊÇ£º“³ÌÐòÔËÐÐʱ£¬ÔÊÐí¸Ä±ä³ÌÐò½á¹¹»ò±äÁ¿ÀàÐÍ£¬ÕâÖÖÓïÑÔ³ÆΪ¶¯Ì¬ÓïÑÔ”¡£´ÓÕâ¸ö¹Ûµã¿´£¬Perl£¬Python£¬RubyÊǶ¯Ì¬ÓïÑÔ£¬C++£¬Java£¬C#²»ÊǶ¯Ì¬ÓïÑÔ¡£
¾¡¹ÜÔÚÕâÑùµÄ¶¨ÒåÓë·ÖÀàÏÂJava²»ÊǶ¯Ì¬ÓïÑÔ£¬ËüÈ´ÓÐ×ÅÒ»¸ö·Ç³£Í»³öµÄ¶¯Ì¬Ïà¹Ø»úÖÆ£ºReflection¡£Õâ¸ö×ÖµÄÒâ˼ÊÇ“·´Éä¡¢Ó³Ïó¡¢µ¹Ó°”£¬ÓÃÔÚJavaÉíÉÏÖ¸µÄÊÇÎÒÃÇ¿ÉÒÔÓÚÔËÐÐʱ¼ÓÔØ¡¢Ì½Öª¡¢Ê¹ÓñàÒëÆÚ¼äÍêȫδ֪µÄclasses¡£»»¾ä»°Ëµ£¬Java³ÌÐò¿ÉÒÔ¼ÓÔØÒ»¸öÔËÐÐʱ²ÅµÃÖªÃû³ÆµÄclass£¬»ñϤÆäÍêÕû¹¹Ô죨µ«²»°üÀ¨methods¶¨Ò壩£¬²¢Éú³ÉÆä¶ÔÏóʵÌå¡¢»ò¶ÔÆäfieldsÉèÖµ¡¢»ò»½ÆðÆämethods¡£ÕâÖÖ“¿´Í¸ class”µÄÄÜÁ¦£¨the ability of the program to examine itself£©±»³ÆΪintrospection£¨ÄÚÊ¡¡¢ÄÚ¹Û¡¢·´Ê¡£©¡£ReflectionºÍintrospectionÊdz£±»²¢ÌáµÄÁ½¸öÊõÓï¡£
ÔÚJDKÖУ¬Ö÷ÒªÓÉÒÔÏÂÀàÀ´ÊµÏÖJava·´Éä»úÖÆ£¬ÕâЩÀ඼λÓÚjava.lang.reflect°üÖУº
ClassÀࣺ´ú±íÒ»¸öÀà¡£
Field Àࣺ´ú±íÀàµÄ³ÉÔ±±äÁ¿£¨³ÉÔ±±äÁ¿Ò²³ÆΪÀàµÄÊôÐÔ£©¡£
MethodÀࣺ´ú±íÀàµÄ·½·¨¡£
Constructor Àࣺ´ú±íÀàµÄ¹¹Ôì·½·¨¡£
ArrayÀࣺÌṩÁ˶¯Ì¬´´½¨Êý×飬ÒÔ¼°·ÃÎÊÊý×éµÄÔªËصľ²Ì¬·½·¨¡£
ÏÂÃæ¸ø³ö¼¸¸öÀý×Ó¿´¿´Reflection APIµÄʵ¼ÊÔËÓãº
Ò»¡¢Í¨¹ýClassÀà»ñÈ¡³ÉÔ±±äÁ¿¡¢³ÉÔ±·½·¨¡¢½Ó¿Ú¡¢³¬Àà¡¢¹¹Ôì·½·¨µÈ
&
Ïà¹ØÎĵµ£º
JAVAµÄ¿çƽ̨µÄÌØÐÔÉîÊÜjava³ÌÐòÔ±ÃǵÄϲ°®,µ«ÕýÊÇÓÉÓÚËüΪÁËʵÏÖ¿çƽ̨µÄÄ¿µÄ,ʹµÃËüºÍ±¾µØ»úÆ÷µÄ¸÷ÖÖÄÚ²¿ÁªÏµ±äµÃºÜÉÙ,´ó´óÔ¼ÊøÁËËüµÄ¹¦ÄÜ,±ÈÈçÓëһЩӲ¼þÉ豸ͨÐÅ,ÍùÍùÒª»¨·ÑºÜ´óµÄ¾«Á¦È¥Éè¼ÆÁ÷³Ì±àд´úÂëÈ¥¹ÜÀíÉ豸¶Ë¿Ú,¶øÇÒÓÐһЩÉ豸³§ÉÌÌṩµÄÓ²¼þ½Ó¿ÚÒѾ¾¹ýÒ»¶¨µÄ·â×°ºÍ´¦Àí,²»ÄÜÖ±½ÓʹÓÃjava³ÌÐòͨ¹ý¶Ë¿ÚºÍÉè± ......
±¾ÎÄת×Ôhttp://blog.csdn.net/nokiaguy/archive/2010/04/16/5493817.aspx
Ëõ·ÅͼÏñµÄ»ù±¾ÔÀíÊÇ´´½¨Ò»¸öÄ¿±ê´óСµÄ»²¼£¬È»ºó¶ÁȡԴͼÏñ£¬²¢½«¸ÃͼÏñ»æÖÆÕâ¸ö»²¼ÉÏ¡£ÎªÁËʹ³ÌÐòͨÓã¬Ô´Í¼ÏñºÍËõ·ÅºóµÄÄ¿±êͼÏñÓ¦Ó÷ֱðʹÓÃ
InputStreamºÍOutputStreamÀ´±íʾ£¬´úÂëÈçÏ£º
public
st ......
°²×°ºÃjdkÒÔºóÐèÒªÌí¼Ó»·¾³±äÁ¿,²ÅÄÜÔÚÃüÁîÐÐÖÐʹÓÃjavaÃüÁî.
ºÜ¶àÈË"ÎÊΪʲôjavacÕÒ²»µ½"¾ÍÊÇÒòΪûÌí¼Ó»·¾³±äÁ¿.
windows ÉÏ¿Éдһ¸ö.bat½Å±¾:
set JAVA_HOME=d:\Java\jdk1.6.0_20
set PATH=%PATH%;%JAVA_HOME%\bin ......
Monkey_peach´úÂë
package com.sailor.game;
/**
* ÌâÄ¿£ººï×Ó³ÔÌÒÎÊÌ⣺ºï×ÓµÚÒ»ÌìÕªÏÂÈô¸É¸öÌÒ×Ó£¬µ±¼´³ÔÁËÒ»°ë£¬»¹²»ñ«£¬ÓÖ¶à³ÔÁËÒ»¸ö µÚ¶þÌìÔçÉÏÓÖ½«Ê£
* ϵÄÌÒ×Ó³ÔµôÒ»°ë£¬ÓÖ¶à³ÔÁËÒ»¸ö¡£ÒÔºóÿÌìÔçÉ϶¼³ÔÁËÇ°Ò»ÌìʣϠ......
Ëü¿ÉÒÔµ¼Èë¿â£¬µ÷ÓÃÍâÃæµÄ¿âº¯Êý£¬javaÓïÑԾͺܺõĵØÀûÓÃÁËÕâÒ»µã£¬jspÒ²¿ÉÒÔÔÚÍøÒ³Öе÷ÓÃjava±àдºÃµÄ³ÌÐò£¬ÒªÊ¹ÓÃjavabean±êÇ©
struts±¾Éí¾ÍÊǶÔjava¼¼ÊõÒ»¸ö°ü×°,°üÀ¨£¬html,jsp¼°±êÇ©,servlet¡£
hibernateÊDZðÈ˱àдºÃÓ³ÉäÊý¾Ý¿âµÄ¹¤¾ß£¬Æä´úÂ붼ÊÇÓÃjavaÓïÑÔ±àдµÄ£¬Ö»ÊÇΪÁË·½±ãÓû§Ê¹Óã¬Óû§Ö»Òªµ¼ÈëÆä¿â£¬µ÷ÓÃÆ ......