public class Solution {
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     * 
     * @param root TreeNode类 
     * @return int整型一维数组
     */
    
    public int[] inorderTraversal (TreeNode root) {
        // write code here
        
        List<Integer> res=new ArrayList<>();//这个允许事先不知道个数
        inorder(root,res);
//格式转换
        int[] ans=new int[res.size()];

        int i=0;
        for(int k:res){
            ans[i]=k;
            i++;
        }
        return ans;

    }
    private void inorder(TreeNode root,List<Integer> res){
        if(root.left!=null) inorder(root.left,res);//左子树
        int get_value=root.val;//获取根
        res.add(get_value);
        if(root.right!=null)//右子树
        inorder(root.right,res);
        
   
    }