1 public BiTNode createBiTree() 2 { 3 Scanner input = new Scanner(System.in); 4 int k = input.nextInt(); 5 if(k == -1) 6 return null; 7 8 BiTNode node = new BiTNode(k); 9 node.lchild = createBiTree();10 node.rchild = createBiTree();11 return node;12 }13 14 public static void main(String[] args)15 {16 BiTree t = new BiTree();17 t.root = t.createBiTree(); //Java的方法均为按值传递 故应该有返回值(区别于C++) 18 }