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

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创建对象,系统会报错,默认的访问权限在不同包中只有实现继承才能调用

相关文章:

  • 2022-12-23
  • 2021-10-01
  • 2022-01-01
  • 2022-02-11
  • 2021-06-09
  • 2021-07-26
  • 2021-12-01
猜你喜欢
  • 2022-01-11
  • 2021-10-17
  • 2021-04-19
  • 2021-10-16
相关资源
相似解决方案