title: How recursive methods are called
body: <p>I am new to Java. I need to know how this recursive method works and how it is called.</p>
  
  <p>Why is "I AM FROM Y" printed 2 times?</p>
  
  <p><strong>Caller</strong>    :    z(3);</p>
  
  <p><strong>Calling Method</strong> </p>
  
  <pre><code>public void z(int i){
  
              int y=i;
              System.out.println("I am from Z");
              if(y&lt;5){
                  z(++i);
                  System.out.println("I AM FROM Y");
              }
  
          }
  </code></pre>
  
  <p><strong>output</strong>: </p>
  
  <blockquote>
  <pre><code>    I am from Z
      I am from Z
      I am from Z
      I AM FROM Y
      I AM FROM Y
  </code></pre>
  </blockquote>