title: How I return specific string from recursive function in java?
body: <p><strong>Input for method :</strong></p>
  <p>word = AbcDef</p>
  <p>input = 3</p>
  <p>w = AbcDef</p>
  <p><strong>The Following code showing the ouput :</strong></p>
  <p>fAbcDe</p>
  <p>efAbcD</p>
  <p>DefAbc</p>
  <p>I want to return only <strong>DefAbc</strong>.
  How can I do the coding for return keyword.</p>
  <pre><code>public static String match2(String word,int input,String w)
  {
      StringBuilder st = new StringBuilder();
      StringBuilder st1 = new StringBuilder();
      String str = &quot;&quot;;
      int count = 0;
              st.append(word.charAt(i));
              
          for(int j = 0;j &lt; i;j++)
          {
              st.append(word.charAt(j));
                    
          }
          
      
                  
      if(input!=0)
      {
          str = st.toString();
          System.out.println(str);
          int input2 = input-1;
          match2(str,input2,w);
      }
      
      return null;
  }
  </code></pre>