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) Basic Android Programming Using the Random Class

There 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?

RandomTest.java
Random randomGenerator = new Random();
Int randomNumber = randomGenerator.nextInt(10);
intAsString = randomNumber + "";

3 Answers

That'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.

Hi 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.

Hi 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

Random randomGenerator= new Random();
int randomNumber = randomGenerator.nextInt(10);
String intAsString = randomNumber +"";