java - Why isn't this work? String value won't change. Recursion -


public class ggg { static int y=0; static int x;  static string h; public static void main(string [] args) {      string s = "hadoyef";     x = s.length();     system.out.println(s);     reverse(s);     system.out.println(s); }  public static string reverse(string s){      if (s.length() == 1){         //system.out.print(s);         h = h + s.substring(0,1);         s=h;         system.out.println(s);         return s;     }     else{         h = h + s.substring(s.length()-1,s.length());         return reverse (s.substring(0, s.length()-1));            //system.out.print(s.substring(0,1));      } } } 

please me dont understand why s=h; part isn't working. ignore here making me post more detail , idk im going ramble until works whoever helps.

when call reverse(s); in main, you're not assigning result anything.


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -