JAVAÖеķ´Éä»úÖÆÏê½â
JAVA·´Éä»úÖÆ
JAVA·´Éä»úÖÆÊÇÔÚÔËÐÐ״̬ÖУ¬¶ÔÓÚÈÎÒâÒ»¸öÀ࣬¶¼Äܹ»ÖªµÀÕâ¸öÀàµÄËùÓÐÊôÐԺͷ½·¨£»¶ÔÓÚÈÎÒâÒ»¸ö¶ÔÏ󣬶¼Äܹ»µ÷ÓÃËüµÄÈÎÒâÒ»¸ö·½·¨£»ÕâÖÖ¶¯Ì¬»ñÈ¡µÄÐÅÏ¢ÒÔ¼°¶¯Ì¬µ÷ÓöÔÏóµÄ·½·¨µÄ¹¦ÄܳÆÎªjavaÓïÑԵķ´Éä»úÖÆ¡£
Java·´Éä»úÖÆÖ÷ÒªÌṩÁËÒÔϹ¦ÄÜ£º ÔÚÔËÐÐʱÅжÏÈÎÒâÒ»¸ö¶ÔÏóËùÊôµÄÀࣻÔÚÔËÐÐʱ¹¹ÔìÈÎÒâÒ»¸öÀàµÄ¶ÔÏó£»ÔÚÔËÐÐʱÅжÏÈÎÒâÒ»¸öÀàËù¾ßÓеijÉÔ±±äÁ¿ºÍ·½·¨£»ÔÚÔËÐÐʱµ÷ÓÃÈÎÒâÒ»¸ö¶ÔÏóµÄ·½·¨£»Éú³É¶¯Ì¬´úÀí¡£
1. µÃµ½Ä³¸ö¶ÔÏóµÄÊôÐÔ
1 public Object getProperty(Object owner, String fieldName) throws Exception {
2 Class ownerClass = owner.getClass();
3
4 Field field = ownerClass.getField(fieldName);
5
6 Object property = field.get(owner);
7
8 return property;
9 }
Class ownerClass = owner.getClass()£ºµÃµ½¸Ã¶ÔÏóµÄClass¡£
Field field = ownerClass.getField(fieldName)£ºÍ¨¹ýClassµÃµ½ÀàÉùÃ÷µÄÊôÐÔ¡£
Object property = field.get(owner)£ºÍ¨¹ý¶ÔÏóµÃµ½¸ÃÊôÐÔµÄʵÀý£¬Èç¹ûÕâ¸öÊôÐÔÊǷǹ«Óеģ¬ÕâÀï»á±¨IllegalAccessException¡£
2. µÃµ½Ä³¸öÀàµÄ¾²Ì¬ÊôÐÔ
1 public Object getStaticProperty(String className, String fieldName)
2 throws Exception {
3 Class ownerClass = Class.forName(className);
4
5 Field field = ownerClass.getField(fieldName);
6
7 Object property = field.get(ownerClass);
8
9 return property;
10 }
Class ownerClass = Class.forName(className) £ºÊ×Ïȵõ½Õâ¸öÀàµÄClass¡£
Field field&n
Ïà¹ØÎĵµ£º
7.3 µã»÷ElementºÍÌîд±íµ¥
ÎÒÃÇ¿ÉÒÔ°²È«µÄ¼ÓÔØÒ³Ãæ£¬³éÈ¡ÐÅÏ¢£¬µ«ÊÇÓÐʱä¯ÀÀÍøÒ³ÊÇÐèÒªÌîд±íµ¥²¢Ìá½»»òÕßµã»÷ij¸öÔªËØÀ´´¥·¢onclickÒÔ±ãÖ´ÐÐÒ»¶Î
JavaScript´úÂë¡£
àÅ£¬ÒªÏëµã»÷Ò»¸öelementÐèÒª»ñµÃÕâ¸öelement(Ç°ÃæµÄxpathNodesÒ²Ðí¿ÉÒÔ°ïÎÒÃÇ×öµ½Õâµã)£¬Èç¹ûÊÇinput element£ ......
“JDK1.5”µÄÒ»¸öÖØÒªÖ÷Ìâ¾ÍÊÇͨ¹ýÐÂÔöÒ»Ð©ÌØÐÔÀ´¼ò»¯¿ª·¢£¬ÕâÐ©ÌØÐÔ°üÀ¨·ºÐÍ£¬for-each¡¡Ñ»·£¬×Ô¶¯×°°ü/²ð°ü£¬Ã¶¾Ù£¬¿É±ä²ÎÊý,¡¡¾²Ì¬µ¼Èë¡¡¡£Ê¹ÓÃÕâÐ©ÌØÐÔÓÐÖúÓÚÎÒÃDZàд¸ü¼ÓÇåÎú£¬¾«º·£¬°²È«µÄ´úÂë¡£
Ò»£® Ê×Ïȼòµ¥½éÉÜһϸ÷ÖÖÌØÐÔ¼°ÆäʹÓÃ
1.·ºÐÍ(Generic)
C++ͨ¹ýÄ£°å¼¼Êõ¿ÉÒÔÖ¸¶¨¼¯ºÏµÄÔªËØÀàÐÍ£¬¶øJ ......
´ó¼Ò¶¼ÖªµÀJAVAÖÐ int ÀàÐÍҪת»¯³É String ÀàÐÍ£¬¿ÉÒÔÓÐÈýÖÖ·½Ê½£¬·Ö±ðÊÇ£º
* (1) String.valueOf(i)
* (2) Integer.toString(i)
* (3) i+""
ÒòΪǰÁ½Ì죬дһ¸ö³ÌÐòʱ£¬ÒªÓõ½ int ת String ,²¢ÇÒÊý¾ÝÁ¿ºÜ´ó£¬Òò´ËÏë¿´¿´ÕâÈýÖÖ·½Ê½µÄЧÂÊÔõÑù£¬Ð´ÁËһϼòµ¥µÄ²âÊÔ³ÌÐò£¬Ôڴ˼ǼһÏ¡£
Java´úÂë
public clas ......
JAVA·´Éä»úÖÆÊÇÔÚÔËÐÐ״̬ÖÐ,¶ÔÓÚÈÎÒâÒ»¸öÀà,¶¼Äܹ»µÃµ½Õâ¸öÀàµÄËùÓÐÊôÐԺͷ½·¨;¶ÔÓÚÈÎÒâÒ»¸ö¶ÔÏó,¶¼Äܹ»µ÷ÓÃËüµÄÈÎÒâÒ»¸ö·½·¨;ÕâÖÖ¶¯Ì¬»ñÈ¡µÄÐÅÏ¢ÒÔ¼°¶¯Ì¬µ÷ÓöÔÏóµÄ·½·¨µÄ¹¦ÄܳÆÎªjavaÓïÑԵķ´Éä»úÖÆ.
¸ÅÀ¨Ò»ÏÂ:
·´Éä¾ÍÊÇÈÃÄã¿ÉÒÔͨ¹ýÃû³ÆÀ´µÃµ½¶ÔÏó(Àà,ÊôÐÔ,·½·¨)µÄ¼¼ ......
´Ë¸öÀàÊÇΪÁË·½±ã³õѧÕß¶ÔXMLµ½ javabean µÄÏ໥ת»»²»ÊìϤ¶øÐ´µÄ:
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;
public class XmlBean {
/*
* @AUTHOR:ZHONG
* @CREATETIME:2010/02/10
* @PREAM:OBJECT(JAVABEAN)
* @RETURN:X ......