Didart

Reverse Strings

Nov 10th, 2021
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ReverseStrings {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         String input = scanner.nextLine();
  8.  
  9.         while (!input.equals("end")) {
  10.            
  11.             String reversed = "";
  12.             for (int index = input.length() - 1; index >= 0; index--) {
  13.                 reversed = reversed + input.charAt(index);
  14.             }
  15.             System.out.printf("%s = %s%n", input, reversed);
  16.            
  17.           input  = scanner.nextLine();
  18.         }
  19.     }
  20. }
  21.  
Advertisement
Add Comment
Please, Sign In to add comment