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

Challenge 3/3 should be solved this way but just isn't...

I tried different ways:

  • sports [3]

  • sports [sports.length - 1]

I just don't get it. Please help!

thx

Array.java
String bestSport = "";
String[] sports = {bestSport, "Basketball", "Baseball", "Tennis" }; 
int numberOfSports = sports.length;
String lastSport = sports[numberOfSports - 1];

Take the variable bestSport out of the array!!!

Then you initialize it with:

lastSport = sports[sports.length - 1];

bestSport should be:

bestSport = sports[0];

Thx Arne! ;-)

Oh, you're so welcome!