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 (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.