易截截图软件、单文件、免安装、纯绿色、仅160KB

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中的接口

        java中接口在开发中占重要地位
   (1)接口中的所有方法都是public abstract
   (2)在接口中声明方法时,不能使用native,static,final,synchronized,private,protect等修饰符,即只能使用public abstract(默认)
    ......

Java类的初始化顺序

我们大家都知道,对于静态变量、静态初始化块、变量、初始化块、构造器,它们的初始化顺序依次是(静态变量、静态初始化块)>(变量、初始化块)>构造器。我们也可以通过下面的测试代码来验证这一点:
 
Java代码
public class InitialOrderTest {   
  
   ......

oracle居然能调用java程序

以前只知道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 ......

传智播客Java培训 反射、注解


反射机制
特点:动态获取类以及类中成员。
通常在程序扩展时,会使用父类或者接口完成,其实就是多态。
在这种情况,运行时,还是需要给其传递一个自定义的子类对象。需要自己new来完成。
虽然修改动作已经很少了,但还是需要修改部分细节。
  interface Inter{void show();}
  class Demo{
   ......

java多叉树遍历

而且java提供的容器类很方便,手工构造了一颗多叉树。然后再递归遍历。类似于中序遍历吧。
树的节点类:
Java代码
package TestTwo;   
  
import java.util.ArrayList;   
import java.util.List;   
  
//多叉树的节点  &nbs ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号