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 (2014) Coding the Fun Facts Using an Array

Shane Emery
Shane Emery
398 Points

Using an Array: Challenge Task 1

How do you solve this?

Shane Emery
Shane Emery
398 Points

I had something along the lines of -

String[] = sports ("Basketball, Baseball, Tennis");

String bestSports = Sports ("0");

I don't think I'm really close to being right, but I am confused :L

Any help would be much appreciated.

4 Answers

Hi Shane,

In an array you use brackets [] not parenthesis (). So the answer is:

String[] sports = { "Basketball", "Baseball", "Tennis" };
String bestSport = sports [0];

If it doesn't work just say.

Shane Emery
Shane Emery
398 Points

Oh dude, that did it. Thank you very much, both of you.

Can we see your best shot at the answer so far?

emmanuel medina
emmanuel medina
2,691 Points

Maybe String bestSports = Sports[0];

Shane Emery
Shane Emery
398 Points

Nope, didn't work. :/

No problem Shane, glad I could help.