This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes I don't know what's wrong with my for loop in method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "I don Watch "I don New topic
Author

I don't know what's wrong with my for loop in method

Tracy Villa
Greenhorn

Joined: Nov 03, 2012
Posts: 28
Hi, so I have a program where I need to generate five random numbers and put them into a array. But my for loop isn't working The error I get is



Here is my code so far:



Please help
Anayonkar Shivalkar
Bartender

Joined: Dec 08, 2010
Posts: 1502
    
    5

Hi Tracy,

This is because you are trying to access ndx from out of its scope.

Hint 1: Look closely. ndx is declared within for loop. It is really being access inside for loop?
Hint 2: Where does your for loop end?


Regards,
Anayonkar Shivalkar (SCJP, SCWCD, OCMJD, OCEEJBD)
Tracy Villa
Greenhorn

Joined: Nov 03, 2012
Posts: 28
Oops I have a semi-colon after my for loop
Tracy Villa
Greenhorn

Joined: Nov 03, 2012
Posts: 28
Thank you so much
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I don't know what's wrong with my for loop in method
 
Similar Threads
Extracting numbers from from a user input and comparing it to
Using the Random Method: How to use random numbers to represent other values?
Error Checking - Can I bypass certain sections of code?
First question in Beginners forum ...
HeadFirst DotComBust... Help?