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

satish singla
satish singla
906 Points

Not able to answer challenge

I am no able to solve the challenge for this video. Please help.

2 Answers

Khaleel Hamid
Khaleel Hamid
5,258 Points

What is the question?

The first challenge asks...

"Declare a String variable named bestSport and initialize it to the first element of the sports array."

so

  1. Declare a string named bestSport... (How do we declare a string? We declare a string like this ex. String name; )
  2. Initialize it to the first element of the sport array (How do we initialize something to an array? Lets say we have an array called... people[3] be initialize our previous string to an element in it like this ex. name = people[2]; )

Now all together in one line...

String name = people [2];  //initializing to the 3rd element of the array

my example shows how to solve the 1st task (it is not the exact solution but it is very close to the exact solution). So try to understand it and try the task again.