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

Declare a String variable named 'bestFrog' and initialize it to the first element of the frogNames array.? what am i missing

String[] frogNames = { "bestfrog", "songie", "joe", "mike",}; String[] frogNames = "bestFrog"; frogNames[0] = bestFrog;

3 Answers

Richmond Lauman
Richmond Lauman
28,793 Points

I just realized this question was concerning JAVA and not PHP as I foolishly assumed in the answer I gave. I don't know JAVA so I have removed my answer so it cannot cause any unnecessary confusion. lol

This should be the line of code you will require. It creates a string variable and assigns 1st value from string array. String bestFrog = frogNames[0];

I think you may have misread the task, as I do at least once a challenge... "bestfrog" shouldn't be in your string array, within the curly brackets. the line Monil wrote in the comment above will take the first value in the frogNames[] string and use that as it's value. because we are using the random number generator we need a number assigned to each of the frog names in the array. The zero in "String bestFrog = frogNames[0]" indicates the first name in the list because we count 0, 1, 2, etc in java. I explained the whole challenge here https://teamtreehouse.com/forum/declare-a-string-variable-named-lastfrog-and-initialize-it-with-the-third-element-of-the-frognames-array good luck.