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

K W
K W
3,736 Points

A little help please......

Declare an int variable named 'numberOfFrogs' and set it to the number of elements in the array using the array's 'length' property.??? my answer*** String[]frogNames = {"mike","ben","kris"}; String bestFrog = frogNames[2]; Random randomGenerator = new Random(); int numberOfFrogs = randomGenerator.Int(frogNames.length);

Valery Kukatov
Valery Kukatov
6,996 Points

You should try to use the Markdown Cheatsheet. The code is very confusing and hard to know what you did wrong when it's written as just text. you have to use three ` before and after the code. This thing called backstick and is located to the left of number 1/ exclamation mark. Once that's done, We can help better. Sorry for the inconvenience.

3 Answers

Valery Kukatov
Valery Kukatov
6,996 Points

Okay, so after I fixed your code. I did the code challenge as well. Your code is almost correct for the challenge. Your error comes up only because you are using randomGenerator. The challenge never asked for the randomGenerator to be placed. As well your bestFrog string is wrong according to challenge, what you put in is the last frog.

K W
K W
3,736 Points

thank you for taking the time to respond

Valery Kukatov
Valery Kukatov
6,996 Points

Well I'd like to help you out if you can fix it. :)

String[]frogNames = {"mike","ben","kris"}; 
String bestFrog = frogNames[2]; 
Random randomGenerator = new Random(); 
int numberOfFrogs = randomGenerator.Int(frogNames.length);
K W
K W
3,736 Points

I got it, thought a randomGenerator was required....thanx again for your time