Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. package hr.riteh.uoop.zad2;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Reverse {
  6.  
  7. public static void main(String[] args) {
  8. Scanner scan=new Scanner(System.in);
  9. String org = new String();
  10. org = scan.nextLine();
  11. System.out.println("Original "+org+", Obrnuto = "+reverse(org)+"");
  12. }
  13. public static String reverse(String org) {
  14. String novi = new String();
  15. for (int i = org.length()-1; i>=0; i--) {
  16. novi = novi+org.charAt(i);
  17. }
  18. return novi;
  19. }
  20.  
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement