Advertisement
veronikaaa86

01. Reverse Strings

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