Skip to content

Instantly share code, notes, and snippets.

@cangevine
Created January 12, 2014 22:22
Show Gist options
  • Save cangevine/8391476 to your computer and use it in GitHub Desktop.
Save cangevine/8391476 to your computer and use it in GitHub Desktop.
public class Reverser {
public static void main(String[] args) {
String input = "1 2 3";
String output = "";
System.out.println("Input :: "+input);
while (input.length() > 0) {
String element = input.substring(input.length() - 1, input.length());
output += element;
input = input.substring(0, input.length() - 1);
}
System.out.println("Output :: "+output);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment