StackOverflowError in java, recursive functions
I keep getting this stackoverflowerror, in java, i'm trying to explore a tree of posibilities for a problem, the thing is i can't find a recursion error in my code, the logic seems fine to me

    

    void StartTree(){//Starts the tree
    for(int i=0;i<Startstack.PLen;i++){
    int [] flip = new int [1];//Creates an array that stores the current flips
    flip[0]=i;//Sets the first flip at i
    PancakeStk CurrentStack = new PancakeStk(Startstack.Pancakes);//Copies the stack into a new stack
    CurrentStack.flip(i);//flips the new stack
    if(CO(CurrentStack,flip)){return;}
    Tree(CurrentStack,flip);//makes a tree over the new stack
    }
    }
    
    void Tree(PancakeStk p, int[] Cflips){
        //<editor-fold defaultstate="collapsed" desc="Check for stop conditions">
        //check for stop conditions
        //array is ordered
        if(CO(p,Cflips)){
        //array is ordered and the depth is the minimum
            return;
        }
        //the tree has reached the maximum depth
        if(Cflips.length==depth){return;}
        //</editor-fold>
        for(int i=0;i<Startstack.PLen;i++){
        if(i==Cflips[Cflips.length-1]){continue;}//if i is equal than the flip before, continue to next flip
        
        else{
            int [] flip = new int [(Cflips.length+1)];//declare array for the flips
            System.arraycopy(Cflips, 0, flip, 0, Cflips.length);//copy the past flips
            flip[Cflips.length-1]=i;//add the current flip
            PancakeStk CurrentStack = new PancakeStk(p.Pancakes);//Copies the stack into a new stack
            CurrentStack.flip(i);//flips the stack in i
            Tree(CurrentStack, flip);//makes a tree over the new stack
        }
        }
    }
    
        boolean CO (PancakeStk p, int[] Cflips){
        if(p.CheckOrder()){
        //array is ordered and the depth is the minimum
            if(Cflips.length<min){
            min = Cflips.length;
            System.arraycopy(zeroarr, 0, flips, 0, zeroarr.length);//initializes the array
            System.arraycopy(Cflips, 0, flips, 0, Cflips.length);//copies the new array
            return true;
            }
        }return false;
        }
        
    }

that was the code, the recursing function is the tree function, although java says the exception is at CO function (stands for checkorder) , im testing this with a trivial case 
the ordered case, and it won't work . :(

i hope you guys can help me
StackOverflowError in java, recursive functions
===

I keep getting this stackoverflowerror, in java, i'm trying to explore a tree of posibilities for a problem, the thing is i can't find a recursion error in my code, the logic seems fine to me

    

    void StartTree(){//Starts the tree
    for(int i=0;i<Startstack.PLen;i++){
    int [] flip = new int [1];//Creates an array that stores the current flips
    flip[0]=i;//Sets the first flip at i
    PancakeStk CurrentStack = new PancakeStk(Startstack.Pancakes);//Copies the stack into a new stack
    CurrentStack.flip(i);//flips the new stack
    if(CO(CurrentStack,flip)){return;}
    Tree(CurrentStack,flip);//makes a tree over the new stack
    }
    }
    
    void Tree(PancakeStk p, int[] Cflips){
        //<editor-fold defaultstate="collapsed" desc="Check for stop conditions">
        //check for stop conditions
        //array is ordered
        if(CO(p,Cflips)){
        //array is ordered and the depth is the minimum
            return;
        }
        //the tree has reached the maximum depth
        if(Cflips.length==depth){return;}
        //</editor-fold>
        for(int i=0;i<Startstack.PLen;i++){
        if(i==Cflips[Cflips.length-1]){continue;}//if i is equal than the flip before, continue to next flip
        
        else{
            int [] flip = new int [(Cflips.length+1)];//declare array for the flips
            System.arraycopy(Cflips, 0, flip, 0, Cflips.length);//copy the past flips
            flip[Cflips.length-1]=i;//add the current flip
            PancakeStk CurrentStack = new PancakeStk(p.Pancakes);//Copies the stack into a new stack
            CurrentStack.flip(i);//flips the stack in i
            Tree(CurrentStack, flip);//makes a tree over the new stack
        }
        }
    }
    
        boolean CO (PancakeStk p, int[] Cflips){
        if(p.CheckOrder()){
        //array is ordered and the depth is the minimum
            if(Cflips.length<min){
            min = Cflips.length;
            System.arraycopy(zeroarr, 0, flips, 0, zeroarr.length);//initializes the array
            System.arraycopy(Cflips, 0, flips, 0, Cflips.length);//copies the new array
            return true;
            }
        }return false;
        }
        
    }

that was the code, the recursing function is the tree function, although java says the exception is at CO function (stands for checkorder) , im testing this with a trivial case 
the ordered case, and it won't work . :(

i hope you guys can help me