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

Brian Jones
Brian Jones
715 Points

Help with array? How is this done?

Declare a String variable named 'bestFrog' and initialize it to the first element of the frogNames array.

2 Answers

Stone Preston
Stone Preston
42,016 Points

you need to index your frogNames array. you can index arrays like so:


keep in mind array indexes start at 0 so the above code selects the 4th item in the array (the first item is index 0, the second is index 1, the third is index 2, and the fourth is index 3 and so on)

so I could create a string variable and assign it an index of an array like so:

String myString = myArray[0];

which would create a new string variable called myString and assign it the value of the first element of the array myArray.

so for the challenge you need to create a string variable called bestFrog and set its value as the first element of the array called frogNames (remember that this is really the 0 index since array indexes start at 0)

Ethan Lowry
Ethan Lowry
Courses Plus Student 7,323 Points

Remember to mark your chosen answers here as accepted so people know the question is solved and the answered gets credit :)