coming out from this method
<p>I have written code below ,and if this <code>else if</code> statement runs I want to come out from this method suddenly and back to the next of the line which this method was called.I have used return but it doesn't work well.</p>

<pre><code>else if (balance == 0 &amp;&amp; noSolution == 0) {
                noSolution = 0;
                return; // it doesn't work.
            }
</code></pre>

<p>METHOD:</p>

<pre><code>    public &lt;E&gt; void rand_Function(List&lt;E&gt; tree, List&lt;E&gt; array) {

    if (array.isEmpty()) {
        return;
    }
    if (array.size() == 1) {
        preorder = (List&lt;Element&gt;) new ArrayList&lt;E&gt;(tree);
        preorder.addAll((Collection&lt;? extends Element&gt;) array);
        for (Element e : preorder) {
            e.setLevel(0);
        }
        E1 = getAverageAccessTime(preorder);
        listTwo = new ArrayList&lt;Element&gt;(preorder);
        if ((E1 &lt; E) || (rand.nextDouble() &lt;= Math.exp(-(Math.abs(E1 - E)) / 0.5 * T))) {
            E = E1;
            listOne = listTwo;

        } else {
            noSolution++;
        }
        balance--;
        System.out.println("running"); // EDITED
        if (balance == 0 &amp;&amp; noSolution ==1) {              
            noSolution = 0;
            T = 0.95 * T;           

        } else if (balance == 0 &amp;&amp; noSolution == 0) {
            System.out.println("running");//EDITED
            noSolution = 0;
            return;//it doesn't work.
        }

    } else {
        for (int i = 0; i &lt; array.size(); i++) {
            //create a list without the ith element
            List&lt;E&gt; newList = new ArrayList&lt;E&gt;(array);
            newList.remove(i);
            //create a list by adding the ith element to beginning
            List&lt;E&gt; newBeginning = new ArrayList&lt;E&gt;(tree);
            newBeginning.add(array.get(i));
            rand_Function(newBeginning, newList);
        }
    }

}
</code></pre>

<p>the function that method above was called :</p>

<pre><code>  private void function(List&lt;Element&gt; list) {
        noSolution = 0;
        listOne = list;
        T = 5;
        balance = 3;
        E = getAverageAccessTime(listOne);
        for (Element e : listOne) {
            e.setLevel(0);
        }
        rand_Function(emptyList, listOne);
        System.out.println("coming out suddenly"); //I want to run this statement when I come out from the method above rand_Function(emptyList, listOne);suddenly!



    }
</code></pre>

<p>output which will return and I don't expect it :</p>

<pre><code>run:
running
running
running
return
running
running
running
running
running
coming out suddenly
</code></pre>

<p>but I need this out put and I expect this one :</p>

<pre><code>run:
running
running
running
return
coming out suddenly
</code></pre>
