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 trialPedro Menezes
377 PointsCannot find symbol
JavaTester.java:66: error: cannot find symbol int numberOfSports = randomGenerator.nextInt[sports.length]; ^ symbol: variable randomGenerator location: class JavaTester 1 error
I didn't understand why it doesn't works. Can anyone help me?
Ty
String[] sports = { "Basketball", "Baseball", "Tennis" };
String bestSport = "Basketball";
int numberOfSports = randomGenerator.nextInt[sports.length];
1 Answer
Chase Marchione
155,055 PointsHi Pedro,
There is no randomGenerator variable in this task, and there is no need for the compiler to look for an integer to be entered: you simply need to set the integer number of sports to the length of (the number of elements in) the sports array.
String[] sports = { "Basketball", "Baseball", "Tennis" };
String bestSport = "Basketball";
int numberOfSports = sports.length;
Hope this helps!