Skip to content

Instantly share code, notes, and snippets.

@asdw3276
Created June 17, 2014 17:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asdw3276/39b2a443c62773fca357 to your computer and use it in GitHub Desktop.
Save asdw3276/39b2a443c62773fca357 to your computer and use it in GitHub Desktop.
1.2
public class reverse{
public static void main(String[] args)
{
String test = "abcdefgterhslaa";
String result = reverse(test);
System.out.println(result);
}
public static String reverse(String s)
{
String result = "";
if(s.equals(null) || s.length() <= 1)
return s;
char temp;
for(int i = s.length() - 1; i >= 0; i--)
{
result = result.concat(s.substring(i,i+1));
}
return result;
}
}
@larry-liu
Copy link

I think the problem asks you to write a function without return value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment