I am trying to reverse user input string my code below is working so that it just output as same as input value..
For example "Hello" will come out "Hello" while result should be "olleH"
This is my code that is in the main as a method call:
System.out.println("Enter a word or phrase you want to be reversed: ");
String s1 = sc.next();
System.out.println("The reversed message is: " + printReverse(s1));
And this is the code that is in my method for the reversal:
public static String printReverse(String str1){
return str1;
}
I know my method is just returning the same message, I did that intentionally as a place holder so that the code would run.
I need to know the most simplest way of doing the reversal, as all examples I have seen use super complex ways of doing this.
Any help is appreciated.