SHARE
TWEET

Untitled

advictoriam Jan 11th, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. /**
  4.    Reads a string, reverses the order the characters within the
  5.    string, and prints out the result.
  6.    Input: the value of s, a string
  7.    Output: the string reversed
  8. */
  9. public class ReverseString
  10. {
  11.    public static void main(String[] args)
  12.    {
  13.       Scanner in = new Scanner(System.in);
  14.       String s = in.nextLine();
  15.  
  16.       String reversed = "";
  17.  
  18.       for(int i = s.length() - 1; i > -1; i--)
  19.       {
  20.          reversed += s.charAt(i);
  21.       }
  22.       System.out.println(reversed);
  23.    }
  24. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top