|
-
February 1st, 2005, 12:32 PM
#1
for loops
I am very new to this and would like a little help. I understand that the for loop has a declaration, a test and an incrementer. What I am trying to do below is print a entered string in reverse.
I keep getting an out of bounds exception because I am reaching 0, the next step being -1.
I just can't seem to work this out. Could someone help please?
This is my code.
for (i=length-1;i<=length;i--)
{
mychar=wordString.charAt(i);
System.out.println(""+mychar);
System.out.println (""+i);
}
My apologies if this is a stupid question
Cheers
Harlequeen
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|