Created
February 15, 2017 07:10
-
-
Save R00We/40372f1f018248cfde3196b05ffc0337 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Main { | |
public static class Reverse { | |
public String reverse(String source) { | |
String [] stringArray = source.split(""); | |
for(int i = 0; i < stringArray.length / 2; i++) | |
{ | |
String temp = stringArray[i]; | |
stringArray[i] = stringArray[stringArray.length - i - 1]; | |
stringArray[stringArray.length - i - 1] = temp; | |
} | |
return Arrays.toString(stringArray); | |
} | |
} | |
public static void main(String[] args) { | |
Reverse reverse = new Reverse(); | |
System.out.print(reverse.reverse("Hello")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment