The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
December 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Help Help - with for(.........................................)

Posted by Fulton Shannon on December 21, 2001 at 7:49 AM

Hello,
Here is my problem: I keep getting out of bound array exception when I run this code:

import java.io.*;
public class Reverse{
public static void main(String args[]){
for(int i = args[0].length()-1; i >= 0; i--)
System.out.print(args[0].charAt(i));
}
}

The program should reverse any string I type at the command line: Java Reverse Foxstream
Am I doing something wrong here? Please check my for loop.

Thanks



Replies:
  • error??? ping203 December 21, 2001 at 10:10 AM (0)

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us