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

Richard Davenport
Richard Davenport
1,663 Points

Stuck yet again

Here is my goal:

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

and here is my code thus far:

String[] frogNames = {
  "bestFrog",
  "mediocreFrog",
  "worstFrog"};

String[] frognames = new bestFrog[0]

2 Answers

You need to declare a variable called bestFrog and set it equal to the first value in the array. If you were to declare a string variable called bestFrog and set it equal to a value, you would do it like this

String bestFrog = "The Green Frog";

And if you had your frogNames array as in the code above and you wanted to do something with the first element in the array (such as print it), you would do it like this

log.i("test", frogNames[0]);

The question wants you to declare a string variable named bestFrog and set it equal to the first value in the array frogNames. So using those two examples as a reference, how would you do that?

Richard Davenport
Richard Davenport
1,663 Points

Got it, was once again, over thinking things. Thank you so much for your help.