Code Snippet: Print String Backwards

From Coder Merlin™

Print String Backwards

Swift

let string = "That Which Survives"
for character in string.reversed() {
    print(character)
}

Python

string = "That Which Survives"
# Short & Fast
print(string[::-1])
# More readable
print(''.join(reversed(string)))

Source

Java

String string = "That Which Survives";
StringBuilder stringBuilder = new StringBuilder(string);
stringBuilder.reverse();
System.out.println(stringBuilder.toString());

// In one line
System.out.println(new StringBuilder(string).reverse().toString());