javaÖй¹Ô캯ÊýµÄµ÷ÓÃ˳Ðò
µ±Ò»¸ö¸´ÔӵĶÔÏó±»¹¹Ôìʱ,ËüµÄ¹¹Ô캯Êý°´ÏÂÃæµÄ˳Ðò±»µ÷ÓÃ(that the order of constructor calls for a complex object is as follows)
1.Æä»ùÀà(base-class)µÄ¹¹Ô캯Êý±»µ÷ÓÃ,Õâ¸ö²½ÖèÒԵݹéµÄ·½Ê½Öظ´,ËùÒÔ×îµ×²ã(the root of hierarchy)µÄ¹¹Ô캯ÊýÊ×Ïȱ»Ö´ÐÐ,È»ºóÊÇËüÉÏÒ»²ãÅÉÉúÀà(the next-derived class)...Ö±µ½×î¶¥²ãµÄÅÉÉúÀà(the most-derived class).
The base-class constructor is called. This step is repeated recursively such that the root of the hierarchy is constructed first, followed by the next-derived class, etc., until the most-derived class is reached.)
2.Èç¹ûÓаüº¬¹ØÏµ(composition),ÄÇôËüµÄ³ÉÔ±¶ÔÏó°´ÕÕÉùÃ÷µÄ˳Ðò±»¹¹Ôì.
Member initializers are called in the order of declaration.
3.ÅÉÉúÀ๹Ô캯ÊýµÄÄÚÈÝ(body)±»Ö´ÐÐ.
The body of the derived-class constructor is called.
Ò»¸öʵÀý:
class Cake{
Cake(){System.out.println("Cake()");}
}
class Meal {
Meal() { System.out.println("Meal()"); }
}
class Bread {
Bread() { System.out.println("Bread()"); }
}
class Cheese {
Cheese() { System.out.println("Cheese()"); }
}
class Lettuce {
Lettuce() { System.out.println("Lettuce()"); }
}
class Lunch extends Meal {
Lunch() { System.out.println("Lunch()"); }
}
class PortableLunch extends Lunch {
//if make derived-class object as the menber of the base-class will lead a infinite
//loop and program will stop because of the memory consumed
//private Sandwich s=new Sandwich();
private Cake a=new Cake();
PortableLunch() {&n
Ïà¹ØÎĵµ£º
×÷Õß
Josh Long
ÒëÕß
ËÎçâ
·¢²¼ÓÚ
2010Äê5ÔÂ5ÈÕ ÏÂÎç9ʱ7·Ö
Josh BlochÔÚSun¹«Ë¾¶àÄêΪJavaƽ̨×÷³öÁ˽ܳö¹±Ï×£¨Èç¹ûÄãÓùýJava
Collections¿ò¼Ü¾Í»áÁ˽âÕâÒ»µã£©£¬ÏÖÔÚGoogle¾ÍÖ°£¬ÊÇ»ñ½±Í¼Êé¡¶Effective ......
ÔÚJavaÖУ¬²»Í¬µÄÀà¶¼ÓÐ×Ô¼ºµ¥¶ÀµÄCache»úÖÆ£¬ÊµÏֵķ½·¨Ò²¿ÉÄÜÓÐËù²»Í¬£¬ÎÄÕÂÁоÙÁËJavaÖг£¼ûµÄ¸÷ÀàCache»úÖÆµÄʵÏÖ·½·¨£¬Í¬Ê±½øÐÐÁË×ۺϵıȽϡ£
OSCache
OSCacheÊǸöÒ»¸ö¹ã·º²ÉÓõĸßÐÔÄܵÄJava EE»º´æ¿ò¼Ü£¬OSCacheÄÜÓÃÓÚÈκÎJavaÓ¦ÓóÌÐòµÄÆÕͨµÄ»º´æ½â¾ö·½°¸¡£
OSCacheÓÐÒÔÏÂÌØµã£º»º´æÈκζÔÏó£¬Äã¿ÉÒÔ²»ÊÜÏÞÖ ......
ÒÔǰֻ֪µÀjavaÄܵ÷ÓÃoracle´æ´¢¹ý³ÌºÍº¯Êý£¬µ«½ñÌìÎÒ·¢ÏÖÔÀ´oracleÒ²¿ÉÒÔµ÷ÓÃjava
²âÊÔ»·¾³oracle 10g
call dbms_java.set_output(5000);
--Ê×ÏÈÔÚoracleÖбàÒëjavaÎļþ ÒÔÏÂÊǸö¼òµ¥µÄ
create or replace and compile java source named helloworld as
public class hellowor ......
¡¡¡¡
ÔÚÃæÏò¶ÔÏó±à³ÌÖУ¬¶ÔÓÚÀ࣬¶ÔÏ󣬷½·¨£¬±äÁ¿µÈ·½ÃæµÄÃüÃûÊǷdz£Óм¼Çɵġ£±ÈÈ磬´óСдµÄÇø·Ö£¬Ê¹Óò»Í¬
×Öĸ¿ªÍ·µÈµÈ¡£µ«¾¿Æä±¾£¬×·ÆäÔ´£¬ÔÚΪһ¸ö×ÊÔ´ÆäÃû³ÆµÄʱºò£¬Ó¦¸Ã±¾×ÅÃèÊöÐÔÒÔ¼°Î¨Ò»ÐÔÕâÁ½´óÌØÕ÷À´ÃüÃû£¬²ÅÄܱ£Ö¤×ÊÔ´Ö®¼ä²»³åÍ»£¬²¢ÇÒÿһ¸ö¶¼±ãÓÚ¼Ç
Òä¡£
......
¡¡¡¡×î½üÒ»Á½¸öÔÂÒÔÀ´Ò»Ö±ÔÚ¿´java ´úÂ룬 ¿´ÁËһЩ¿ªÔ´µÄʵÏÖ£¬ Ò²¿´ÁËһЩ²úÆ·ÖеĴúÂ룬´ÓÕâЩ´úÂëÖУ¬Ñ§Ï°ÁËһЩ¿ªÔ´¿ò¼ÜµÄÓ¦Óã¨ÈçActiveMQ£¬cxf£©£¬Ò²Ñ§Ï°ÁËÕâЩ¿ò¼ÜµÄʵÏÖ£¬Í¬Ê±Ò²×¢ÒâÈ¥Àí½âÿ¸öÀà ÒÔ¼°½Ó¿ÚµÄÉè¼Æ£¬ÒÔ¼°Éè¼ÆÄ£Ê½µÄÓ¦Ó㬠¹Ø×¢ÁËһϣ¬Ã¿¸öÀ࣬½Ó¿ÚµÄ¹æÄ££¬»ù±¾ÉÏÓÐһЩҲ»á·Ç³£´ó£¬Óм¸Ç§ÐУ¬ÓÐһЩ ......