Java·´Éä2
1.2.3.ConstructorÀࣺ
ConstructorÀà´ú±íij¸öÀàµÄÒ»¸ö¹¹Ôì·½·¨¡£
µÃµ½Ä³¸öÀàËùÓеĹ¹Ôì·½·¨£º
Constructor[] constructor = Class.forName(“java.lang.String”).getConstructor();
µÃµ½Ä³Ò»¸ö¹¹Ôì·½·¨£º
Constructor constructor =
Class.forName(“java.lang.String”).getConstructor(StringBuffer.class);
´´½¨ÊµÀý¶ÔÏó£ºString str2 = (String)constructor1.newInstance(new StringBuffer("abc"));
1.2.4.FieldÀࣺ
Field´ú±íij¸öÀàµÄÒ»¸ö³ÉÔ±±äÁ¿¡£ÌṩÓйØÀà»ò½Ó¿ÚµÄÊôÐÔµÄÐÅÏ¢£¬ÒÔ¼°¶ÔËüµÄ¶¯Ì¬·ÃÎÊȨÏÞ¡£·´ÉäµÄ×ֶοÉÄÜÊÇÒ»¸öÀࣨ¾²Ì¬£©ÊôÐÔ»òʵÀýÊôÐÔ£¬¼òµ¥µÄÀí½â¿ÉÒÔ°ÑËü¿´³ÉÒ»¸ö·â×°·´ÉäÀàµÄÊôÐÔµÄÀà¡£
public void setAccessible(boolean flag)
ÉèÖÃÊÇ·ñÓÐȨÏÞ·ÃÎÊ·´ÉäÀàÖеÄ˽ÓÐÊôÐԵģ¬Ö»ÓÐÉèÖÃΪtrueʱ²Å¿ÉÒÔ·ÃÎÊ£¬Ä¬ÈÏΪfalse¡£
public void set(Object obj,Object value)
ÉèÖÃÖ¸¶¨ÊôÐÔµÄÖµ¡£
public Object get(Object obj)
µÃµ½ÊôÐÔµÄÖµ
ÎÊÌ⣺µÃµ½µÄField¶ÔÏóÊǶÔÓ¦µ½ÀàÉÏÃæµÄ³ÉÔ±±äÁ¿£¬»¹ÊǶÔÓ¦µ½¶ÔÏóÉϵijÉÔ±±äÁ¿£¿ÀàÖ»ÓÐÒ»¸ö£¬¶ø¸ÃÀàµÄʵÀý¶ÔÏóÓжà¸ö£¬Èç¹ûÊÇÓë¶ÔÏó¹ØÁª£¬ÄǹØÁªµÄÊÇÄĸö¶ÔÏóÄØ£¿
²âÊÔ´úÂ룺
public class ReflectPoint {
private int x;
public int y;
public ReflectPoint(int x, int y) {
this.x = x;
this.y = y;
}
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
}
²âÊÔ´úÂ룺
ReflectPoint pt1 = new ReflectPoint(3,5);
Field fieldY = pt1.getClass().getField("y");
//fieldYµÄÖµÊǶàÉÙ£¿ÊÇ5,´í£¡fieldY²»ÊǶÔÏóÉíÉϵıäÁ
Ïà¹ØÎĵµ£º
Javaѧϰ´ÓÈëÃŵ½¾«Í¨
Ò»¡¢ JDK (Java Development Kit)
JDKÊÇÕû¸öJavaµÄºËÐÄ£¬°üÀ¨ÁËJavaÔËÐл·¾³£¨Java Runtime Envirnment£©£¬Ò»¶ÑJava¹¤¾ßºÍJava»ù´¡µÄÀà¿â(rt.jar)¡£²»ÂÛʲôJavaÓ¦Ó÷þÎñÆ÷ʵÖʶ¼ÊÇÄÚÖÃÁËij¸ö°æ±¾µÄJDK¡£Òò´ËÕÆÎÕJDKÊÇѧºÃJavaµÄµÚÒ»²½¡£×îÖ÷Á÷µÄJ ......
±àÒëʱ´ò°ü£º
javac -d "Òª°Ñ°ü´òµ½ÄÄ£»ÅÌ·û»òÕß.(.±íʾµ±Ç°Ä¿Â¼)" ÎļþÃû.java
Ö´Ðдò°üµÄ.classÎļþ
java -cp(cp´ú±íÁÙʱµÄ»·¾³±äÁ¿) "ÊäÈë.classÎļþËùÔÚµÄÅÌ·û£¬Èç¹ûÔÚµ±Ç°Îļþ¼Ð£¬¾ÍÊäÈë“.”" "¼Èë.classÎļþËùÔڵķ¾¶£¨°üÀ¨ÎļþÃû£¬²»ÐèÒª´ò.java£©"
ÉèÖÃÁÙʱ»·¾³±äÁ ......
ÒÔÒ»¸ö¹¤×÷ÖбàдµÄ°²È«ÓòÐÅϢͬ²½ÎªÀý½øÐÐÃèÊö;
°²È«ÓòÐÅϢͬ²½Æäʵ¾ÍÊÇÒ»¸öXMLÎļþµÄ´«Êä,WEB SERVICE ±¾ÖÊÉϾÍÊÇͨ¹ýXML½øÐÐÊý¾ÝµÄ´«Êä.
´«ÊäµÄXML¸ñʽÈçÏÂ:
<?xml version="1.0" encoding="UTF-8" ?>
- <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV: ......
ÕýÔò±í´ïʽÊÇÓÃÀ´Ð£ÑéÎı¾¿òÖÐËùÊäÈëµÄÖµÊÇ·ñÆ¥Åä¡£Ò»°ãÔÚswingÀïÃæºÍjs½Å±¾Ð£ÑéÖÐÓõÃÂù¶àµÄ¡£
ϲ»¶ÉÏÕýÔòÊÇÔÚÒ»´Î×öСÊýµãµÄÑéÖ¤ÉÏ£¬¾ÍÊÇÒªÅжÏÊäÈëµÄÖµµÄ³¤¶ÈÔÚ5룬¿ÉÒÔÓÐСÊýµã¡£Èç¹û²»ÓÃÕýÔò£¬ÄÇôÎÒµÃÅжÏСÊýµãÊDz»ÊÇÖ»ÓÐÒ»¸ö£¬Ð¡ÊýµãÊDz»ÊÇÔÚµÚһ룬ÊDz»ÊÇÔÚ×îºóһ룬ÄÇЩÇé¿ö¶¼ÒªÅųýµÄ¡£µ±È»£¬ÕâÑù×öһϣ¬¿É ......
1.¼ÆËãijһÔ·ݵÄ×î´óÌìÊý
Calendar time=Calendar.getInstance();
time.clear();
time.set(Calendar.YEAR,year); //year Ϊ int
time.set(Calendar.MONTH,i-1);//×¢Òâ,Calendar¶ÔÏóĬÈÏÒ»ÔÂΪ0
int day=time.getActualMaximum(Calendar ......