// function1(root); // function2(root); function3(root); } class TreeNode { String value; TreeNode left; TreeNode right; TreeNode(String value) { this.value = value; } } //根左右 void function1(TreeNode current) { if (current == null) { return; } log(current); function1(current.left); function1(current.right); } //左根右 void function2(TreeNode current) { if (current == null) { return; } function2(current.left); log(current); function2(current.right); } //左右根 void function3(TreeNode current) { if (current == null) { return; } function3(current.left); function3(current.right); log(current); } void log(TreeNode node) { if (node != null) { Log.i(TAG, node.value); } }