Skip to content

Instantly share code, notes, and snippets.

@R00We
Created February 15, 2017 07:10
Show Gist options
  • Save R00We/40372f1f018248cfde3196b05ffc0337 to your computer and use it in GitHub Desktop.
Save R00We/40372f1f018248cfde3196b05ffc0337 to your computer and use it in GitHub Desktop.
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