2 Replies Latest reply: Feb 2, 2008 11:52 PM by 807601 RSS

    How do I make this an array

    807601
      The application so far here reverses a word. What has to be done to make it an array that displays the reversed word one letter per line.
      package arrayreverse;
      import java.util.Scanner;
      
      public class arrayreverse {
       
          /** Creates a new instance of ArrayReverse */
          public arrayreverse() {
          }
       
          /**
           * @param args the command line arguments
           */
          public static void main(String[] args) {
      
      
      
      {
       Scanner input = new Scanner(System.in);
          String word;
         System.out.println("Write the word you want reversed.");
          word = input.nextLine();
      String testString =word;
      String revString = "";
      int len = testString.length();
      
      for(int i = len -1 ;i >=0 ;i--)
      {
      revString+=testString.charAt(i);
      }
      
      System.out.println(revString);
      }
              
          }
      }