Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class ForLoopString{
- public static void main (String []args){
- Scanner input = new Scanner(System.in);
- System.out.println("Input a word:");
- String word = input.nextLine();
- String reverseword = " ";
- char lastletter = word.charAt(word.length() - 1);
- for(int i = word.length()-1; i >= 0; i--){
- reverseword=reverseword + word.charAt(i);}
- System.out.println(word.charAt(0));
- System.out.println(lastletter);
- System.out.println(reverseword);
- System.out.println(word);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement