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

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:

arrayName[3]

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 :)