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

Eugene Proctor
Eugene Proctor
1,489 Points

What is wrong with randomGenerator.nextint()on my second line?

I get an error that indicates the period is a syntax error in the second line of my code. beside randomGenerator.nextint();

RandomTest.java
Random randomGenerator = new Random();
int randomNumber = randomGenerator.nextint();

1 Answer

Not sure if you checked the Preview to see the error message, but if not here's what it showed:

JavaTester.java:65: error: cannot find symbol
int randomNumber = randomGenerator.nextint();
                                  ^
  symbol:   method nextint()
  location: variable randomGenerator of type Random
1 error

It's trying to tell you that there's no nextint() method. That's because the method is nextInt(), with a capital I. Let me tell you, it's a mistake we've all made at one time or another!