title: Breaking out of a recursion method in java
body: <p>How to save "flag" when i set it. For exemple, when i am in block</p>
  
  <pre><code>if (hashFunction(value) == hashFunction(node.value))
  {
  
      flag = true;
      return flag; 
  
  }
  </code></pre>
  
  <p>in debug flag = true, but next step and pointer is in </p>
  
  <pre><code>if (hashFunction(value) &lt; hashFunction(node.value))
      {
          if (node.left != null)
          {
  
              findPrivate(value, node.left);------THERE
  
          } else
          {
              flag = false;
              return flag;
          }
      }
  </code></pre>
  
  <p>And in result, my method return false. How to fix it? Sorry for my english. Full code is bellow.</p>
  
  <pre><code>    private boolean findPrivate(T value, Node node)
  {
  
      if (node == null)
      {
          flag = false;
          return flag;
  
      }
      if (hashFunction(value) == hashFunction(node.value))
      {
  
          flag = true;
          return flag; 
  
      }
  
      if (hashFunction(value) &gt; hashFunction(node.value))
      {
          if (node.rigth != null)
          {
              findPrivate(value, node.rigth);
          } else
          {
  
              flag = false;
              System.out.println("value= " + value + " " + flag);
              return flag;
          }
      }
  
      if (hashFunction(value) &lt; hashFunction(node.value))
      {
          if (node.left != null)
          {
  
              findPrivate(value, node.left);
  
          } else
          {
              flag = false;
              return flag;
          }
      }
      return flag;
  }
  </code></pre>