关于JAVA访问权限

===========================

package J2EE;
public class Node {   

public Object value;   

public Node left;   

public Node right;   

public Node(){   

this.left=null;   

this.right=null;   

this.value=null; 

  }   

public Node(Object value){   

this.value=value;   

this.left=null;   

this.right=null; 

  }   

public  Node(Object value,Node left,Node right){   

this.left=left;   

this.right=right;   

this.value=value;   

}}

在J2EE中的Node类..

================================

package datastruct;

import J2EE.Node;

public class Exchange {

private Node root;

private Node node_one;

private Node node_two;

private Node node_three;

private Node node_four;

public int size; Exchange(){//注意创建节点的顺序,从叶节点开始创建,在到根节点

node_one=new Node(4);

node_three=new Node(3);

node_four=new Node(2);

node_three=new Node(3,node_four,null);

root=new Node(5,node_one,node_three);

}

public static void main(String[] args) { // TODO Auto-generated method stub
}
}

这个是在包datastract中的Exchange类..

如果在Node中的构造方法为默认,你在Exchange中调用NODE创建对象,系统会报错,默认的访问权限在不同包中只有实现继承才能调用

posted @ 2011-04-22 11:11  Together,  阅读(316)  评论(0编辑  收藏  举报