-
-
Save asdw3276/39b2a443c62773fca357 to your computer and use it in GitHub Desktop.
1.2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think the problem asks you to write a function without return value.