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!
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

Matthew Hillberg
722 PointsJava Array
I got started on the array and i always mess up on them. I did the string of bestSport
String bestSport = sports []
and it says a Syntax error
4 Answers

Chris Shaw
26,663 PointsHi Matt,
You're very close to the correct answer, the challenge task is asking you to select the first item from the sports
array and if you remember arrays always start at the index 0 therefore we can simply target the value Basketball by using the index 0.
String bestSport = sports[0];
Happy coding.

Nicholas Romano
3,223 PointsTo initialize a string array with a set size use
String bestSports[] = new String[20];
// 20 being the length of the array to initialize

Stone Preston
42,016 Pointsyour second example does not intialize the array, it just declares it. You cannot initialize an array without a fixed size in java.

Nicholas Romano
3,223 PointsGood point, just edited it thanks!

Matthew Hillberg
722 PointsOdd, doesn't seem to work when I enter it in. I tired doing the == and taking out the number but it still says syntax error.

Jeff Busch
19,287 PointsHi Matthew,
Try this:
String bestSport = sports[0];