KahnClifford

Reverse word in a sentence

Dec 11th, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Main{
  3. public static void main(String[] args) {
  4. String word1;
  5. char[] wordCh;
  6. String word2;
  7.  
  8. Scanner input = new Scanner(System.in);
  9. word1 = input.next();
  10. word2 = input.next();
  11. wordCh = word1.toCharArray();
  12.  
  13. for(int x=wordCh.length-1;x>=0;--x) {
  14. System.out.print(wordCh[x]);
  15. }
  16. System.out.print(" "+word2);
  17. }
  18.  
  19. }
Add Comment
Please, Sign In to add comment