Skip to content

Instantly share code, notes, and snippets.

@shihyu
Created September 22, 2018 01:28
Show Gist options
  • Save shihyu/e6acfc206928b2cbb3011ea193fe1c4f to your computer and use it in GitHub Desktop.
Save shihyu/e6acfc206928b2cbb3011ea193fe1c4f to your computer and use it in GitHub Desktop.
import java.util.Random;
import java.util.Scanner;
import java.io.*;
public class Main
{
public static String reverse(String originalStr)
{
String resultStr = "";
for (int i = originalStr.length() - 1 ; i >= 0 ; i--) {
resultStr = resultStr + originalStr.charAt(i);
}
System.out.println(Integer.toHexString(resultStr.hashCode()));
return resultStr;
}
public static void main(String[] args) throws IOException {
String s = new String("hello world");
String result = reverse(s);
System.out.println(Integer.toHexString(result.hashCode()));
System.out.println(result);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment