Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Nicola Sansom
1,306 PointsThere is a compiler error. Please click on preview to view your syntax errors!
I entered in “intAsString = randomNumber + “”; but I am getting a “There is a compiler error. Please click on preview to view your syntax errors! “ I checked the preview but do not understand what I have done wrong any ideas?
Random randomGenerator = new Random();
Int randomNumber = randomGenerator.nextInt(10);
intAsString = randomNumber + "";
3 Answers

Steve Hunter
57,682 PointsThat's a new error caused because you've not declared intAsString
to be a String. Add the word String
before it:
String intAsString = randomNumber + "";
That should sort it for you.
Steve.

Steve Hunter
57,682 PointsHi Nicola,
You should change Int
to int
as you declare the randomNumber
variable - that one letter could be causing the problems you're experiencing!
int randomNumber = randomGenerator.nextInt(10);
Steve.

Nicola Sansom
1,306 PointsHi I just tried changing it to a lowercase letter but still having trouble this is what the preview screen says
JavaTester.java:67: error: cannot find symbol intAsString = randomNumber + ""; ^ symbol: variable intAsString location: class JavaTester JavaTester.java:111: error: cannot find symbol if (!(intAsString instanceof String)) { ^ symbol: variable intAsString location: class JavaTester JavaTester.java:115: error: cannot find symbol if (!intAsString.equals(Integer.toString(randomNumber))) { ^ symbol: variable intAsString location: class JavaTester 3 errors

raajiabraham
2,609 PointsRandom randomGenerator= new Random();
int randomNumber = randomGenerator.nextInt(10);
String intAsString = randomNumber +"";