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

¡¾×ª¡¿JavaÖÐtoString()·½·¨

1£®toString£¨£©·½·¨
ObjectÀà¾ßÓÐÒ»¸ötoString()·½·¨£¬Äã´´½¨µÄÿ¸öÀ඼»á¼Ì³Ð¸Ã·½·¨¡£Ëü·µ»Ø¶ÔÏóµÄÒ»¸öString±íʾ£¬²¢ÇÒ¶ÔÓÚµ÷ÊԷdz£ÓаïÖú¡£È»¶ø¶ÔÓÚĬÈϵÄtoString()·½·¨ÍùÍù²»ÄÜÂú×ãÐèÇó£¬ÐèÒª¸²¸ÇÕâ¸ö·½·¨¡£
toString£¨£©·½·¨½«¶ÔÏóת»»Îª×Ö·û´®¡£¿´ÒÔÏ´úÂ룺
package sample;
class Villain {
    private String name;
    protected void set(String nm) {
       name = nm;
    }
    public Villain(String name) {
       this.name = name;
    }
    public String toString() {
       return "I'm a Villain and my name is " + name;
    }
}
public class Orc extends Villain {
    private int orcNumber;
    public Orc(String name, int orcNumber) {
       super(name);
       this.orcNumber = orcNumber;
    }
    public void change(String name, int orcNumber) {
       set(name);
       this.orcNumber = orcNumber;
    }
    public String toString() {
       return "Orc" + orcNumber + ":" + super.toString();
    }
    public static void main(String[] args) {
       Orc orc = new Orc("Limburger", 12);
       System.out.println(orc);
       orc.change("Bob", 19);
       System.out.println(orc);
    }
}
½á¹û£º
sample.Orc@11b86e7
sample.Orc@11b86e7
Èç¹ûÈ¥µô×¢ÊÍ£¬¼´¼ÓÈë2¸ötoString£¨£©·½·¨ºó£¬µÃµ½
½á¹û£º
Orc12:I'm a Villain and my name is Limburger
Orc19:I'm a Villain and my name is Bob
2£®ÔÚÈÝÆ÷ÀàÖÐʹÓÃtoString()
±àдһ¸ö¹¤¾ßÀ࣬ÓÃÓÚÔÚ¿ØÖÆ̨Êä³öIterator¡£
import java.


Ïà¹ØÎĵµ£º

java¶¯Ì¬´úÀíÀà

 
Java¶¯Ì¬´úÀíÀàλÓÚjava.lang.reflect°üÏ£¬Ò»°ãÖ÷ÒªÉæ¼°µ½ÒÔÏÂÁ½¸öÀࣺ
(1)Interface InvocationHandler£º¸Ã½Ó¿ÚÖнö¶¨ÒåÁËÒ»¸ö·½·¨
§public object invoke(Object obj,Method method, Object[] args)
ÔÚʵ¼ÊʹÓÃʱ£¬µÚÒ»¸ö²ÎÊýobjÒ»°ãÊÇÖ¸´úÀíÀ࣬methodÊDZ»´úÀíµÄ·½·¨£¬ÈçÉÏÀýÖеÄrequest()£¬argsΪ¸ ......

java¶¯Ì¬´úÀí

 
¶¯Ì¬´úÀíÊÇÖ¸¿Í»§Í¨¹ý´úÀíÀàÀ´µ÷ÓÃÆäËü¶ÔÏóµÄ·½·¨
¶¯Ì¬´úÀíʹÓó¡ºÏ:

Ô¶³Ì·½·¨µ÷ÓÃ(RMI)

 
1.´´½¨Ò»¸öʵÏÖ½Ó¿ÚInvocationHandlerµÄÀ࣬Ëü±ØÐëʵÏÖinvoke·½·¨
2.´´½¨±»´úÀíµÄÀàÒÔ¼°½Ó¿Ú
3.ͨ¹ýProxyµÄ¾²Ì¬·½·¨
newProxyInstance(ClassLoader loader, Class[] interfaces, Invocat ......

DelphiÖÐʵÏÖC++/JavaÀàËƾ²Ì¬±äÁ¿µÄ¹¦ÄÜ

ÔÚÍøÉÏ¿´µ½ºÜ¶àÈ˶¼ÔÚΪDelphiÊÇ·ñÖ§³ÖC++/JavaÖеľ²Ì¬±äÁ¿¼°¾²Ì¬·½·¨µÄ¹¦ÄܶøÀ§ÈÅ,ÆäʵÕâÔÚDelphiÖÐÊǺܼòµ¥µÄ.
¾²Ì¬·½·¨¾ÍÊÇʹÓÃClass Function. ¾²Ì¬±äÁ¿ÔòʹÓõ¥Ôª¾Ö²¿±äÁ¿À´ÊµÏÖ. ´úÂëÈçÏÂ:
//=========================================
// StaticVarTestU - ¶¨ÒåÁË¿ÉÒÔ¼ÆÊýµÄÀ࣬ͨ¹ýÀà·½·¨¼´¿É·ÃÎÊ´ËÀàµÄ¶ÔÏóÊý ......

ÍƼöÒ»¿îJava·´±àÒëÆ÷£¬±È½ÏºÃÓÃ

 ÍƼöÒ»¿îJava·´±àÒëÆ÷£¬Ò²Ê¹ÓÃÁËͦ¾ÃµÄÁË£¬¸Ð¾õ»¹ÊǺܺÃÓ㬾ÍÄóöºÍ´ó¼Ò·ÖÏíһϡ£
Õâ¿î·´±àÒëÆ÷½Ð "Java Decompiler", ÓÉ Pavel Kouznetsov¿ª·¢£¬Ä¿Ç°×îа汾Ϊ0.2.5.
ËüÓÉ C++¿ª·¢£¬²¢ÇÒ¹Ù·½¿ÉÒÔÏÂÔØ windows¡¢linuxºÍÆ»¹ûMac OsÈý¸öƽ̨µÄ¿ÉÖ´ÐгÌÐò¡£
   ±¾ÈËÖ®ËùÒÔÈÏΪËü»¹²»´í£¬ÊÇÆäÓÐÏÂÃ漸¸ö¹ ......

¹ØÓÚ Java ¶ÔÏóÐòÁл¯Äú²»ÖªµÀµÄ 5 ¼þÊÂ

Java ÐòÁл¯¼ò½é
Java ¶ÔÏóÐòÁл¯ÊÇ JDK 1.1 ÖÐÒýÈëµÄÒ»×鿪´´ÐÔÌØÐÔÖ®Ò»£¬ÓÃÓÚ×÷ΪһÖÖ½« Java ¶ÔÏóµÄ״̬ת»»Îª×Ö½ÚÊý×飬ÒÔ±ã´æ´¢»ò´«ÊäµÄ»úÖÆ£¬ÒÔºó£¬ÈÔ¿ÉÒÔ½«×Ö½ÚÊý×éת»»»Ø Java ¶ÔÏóÔ­ÓеÄ״̬¡£
ʵ¼ÊÉÏ£¬ÐòÁл¯µÄ˼ÏëÊÇ “¶³½á” ¶ÔÏó״̬£¬´«Êä¶ÔÏó״̬£¨Ð´µ½´ÅÅÌ¡¢Í¨¹ýÍøÂç´«ÊäµÈµÈ£©£¬È»ºó “½ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ