Created
November 6, 2019 05:50
-
-
Save gitaficionado/fca0398b53a313f2af188fa470240212 to your computer and use it in GitHub Desktop.
(Reverse a string) Write a program that prompts the user to enter a string and displays the string in reverse order.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class ReverseAStringExercise_05_46 { | |
public static void main(String[] args) { | |
Scanner input = new Scanner(System.in); | |
System.out.print("Enter a string: "); | |
__________________________________ | |
String result = ""; | |
for (int i = __; ___ < s.length(); ____) { | |
result = s.charAt(i) + result; | |
} | |
System.out.println("The reversed string is " + result); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment