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 Generating a Random Number

When I run my app it is work fine but I couldn't get the random number 0 1 2 instate i get java@ some number.???

please tell me if I did something wrong !!

Can you post your code?

thanks I forgot out how to solve it

I am getting the same thing. My code is [CODE] public void onClick(View v) { //The button was clickes, so update the fact label with a new fact. String fact = ""; //Randomly select a fact Random randomGenerator = new Random(); //construct a new Random number generator int randomNumber = randomGenerator.nextInt(3); fact = randomGenerator + ""; //Update the label with our dynamic text factLabel.setText(fact); } [/CODE]

Never mind. I just figured it out. I was accidentally calling randomGenerator instead of randomNumber at the end.

1 Answer

Make sure you wrote down that fact = randomNumber and not randomGenerator