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
Ïà¹ØÎĵµ£º
javaÖнӿÚÔÚ¿ª·¢ÖÐÕ¼ÖØÒªµØÎ»
£¨1£©½Ó¿ÚÖеÄËùÓз½·¨¶¼ÊÇpublic abstract
£¨2£©ÔÚ½Ó¿ÚÖÐÉùÃ÷·½·¨Ê±£¬²»ÄÜʹÓÃnative£¬static£¬final£¬synchronized£¬private£¬protectµÈÐÞÊηû£¬¼´Ö»ÄÜʹÓÃpublic abstract£¨Ä¬ÈÏ£©
......
תÌûthisµÄÓ÷¨·½±ã×Ô¼ºÒÔºó²é¿´
±ØÐëÓÃthis¹Ø¼ü×ÖµÄÈýÖÖÇé¿ö:
1¡¢ÎÒÃÇÏëͨ¹ý¹¹Ôì·½·¨½«Íⲿ´«ÈëµÄ²ÎÊý¸³Öµ¸øÀàµÄ³ÉÔ±±äÁ¿£¬¹¹Ôì·½·¨µÄÐÎʽ²ÎÊýÃû³ÆÓëÀàµÄ³ÉÔ±±äÁ¿ÃûÏàͬ¡£ÀýÈ磺
class Person
.. ......
1.Çëд³öÏÂÁÐJava´úÂëµÄÊä³ö½á¹û
package test;
public class FatherClass()
{ public FatherClass()
&n ......
ÒÔǰֻ֪µÀ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 ......
µÚÒ»£ºÒªÉèÖÃSQL ServerµÄTCP/IP·þÎñ
1) ´ò¿ªSQL Server Configuration Manager”,Ë«»÷“SQL Server 2005ÍøÂçÅäÖÔ£¬µã»÷“*** µÄÐÒé” (×¢Ò⣺***´ú±íʵÀýÃüÃû£¬ÀýÈ磺accpDBµÄÐÒé)
2) Ñ¡ÔñÓұߴ°¿ÚÖеēTCP/IP”ÐÒ飬ÓÒ¼üµ ......