Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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