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

megankirkland
663 PointsAm I not initializing the string name to first variable of the array correctly?
{
String[] sports = { "Basketball", "Baseball", "Tennis" };
String bestSport = "";
int bestSport = sports.nextInt(Basketball);
}
1 Answer

Gabriel Tartaglia
41,581 PointsHi Megan!
To get an item from an array, you need to call the array followed by brackets with the index of the item in it, like sports[0]. It not helps a lot, right?
Well, an array has multiple items, each item has its numerical index. Index numbering begins with 0, so the first item has the index 0, the second has index 1 and so on. A good tip is the item you want minus 1.
Can you access correctly now? Give a try, but if it not works yet, here is the answer:
String[] sports = { "Basketball", "Baseball", "Tennis" };
String bestSport = sports[0];
megankirkland
663 Pointsmegankirkland
663 PointsThank you for the help! I really appreciate it!