write a recursive method that accepts a single String as a parameter and returns the reverse of that String. For example, calling the method reverse("Test would return the String "tesT".
any suggestion?
Thanks in advance
Printable View
write a recursive method that accepts a single String as a parameter and returns the reverse of that String. For example, calling the method reverse("Test would return the String "tesT".
any suggestion?
Thanks in advance
Code :String example = "Hello, World!"; System.out.println( (new StringBuffer(example)).reverse() );
That should get you going :) You will need imports etc too hehe xD
P.S Sorry for the slow reply
Regards,
Chris
hi,
wlecome to the java prog forums.
here is the code: http://www.javaprogrammingforums.com...e-program.html
above is the sample code.
Cheers.
Truffy \m/
Code :Public String someMethod(String input) { String output=""; Char[] reverse=new Char[input.length()]; reverse=input.tochararray(); for(int i=input.length();i>=0;i--) { output+=Character.toString(reverse[i]) } return output; }
keep in mind this is a skeleton method and most likely doesn't work due to the fact Im not in front of an IDE to test this out in :eek:. i just wanted you to get the idea. Oh this is not recursive btw.(sorry).