Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Build a Simple Android App (retired 2014) Learning the Language Introduction to Arrays

reginald everett
PLUS
reginald everett
Courses Plus Student 1,862 Points

Please! i need help with this section stage 2 learning the language. I am on the array section and i'm stuck

(this is what the challenge was)

Declare an int variable named 'numberOfFrogs' and set it to the number of elements in the array using the array's 'length' property.

(the last line was the answer i put in) String[] frogNames = { "mike", "ike", "tyke"}; String bestFrog = "mike"; int numberOfFrogs = randomGenerator.nextInt(frogNames.length);

(and here is the error message) JavaTester.java:24: cannot find symbol symbol : variable randomGenerator location: class JavaTester int numberOfFrogs = randomGenerator.nextInt(frogNames.length); ^ 1 error

2 Answers

Don't know exactly what the error is, but your task is simply to get the number of elements in the array. You however create a random number in the range of the array. int numberOfFrogs = randomGenerator.nextInt(frogNames.length); gives you a random number between 0 and 2 int numberOfFrogs = frogNames.length; gives you just 2.. all you need