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

David Hume
David Hume
10,334 Points

I'm getting this error when I try to run my code: Error:(35, 55) error: package randomGenerator does not exist

Here's the code: public void onClick(View v) { //the button was clicked - update TextView with new fact String fact = ""; //RANDOMLY SELECT A FACT //first IMPORT class: Random randomGenerator = new Random(); //create variable to store randomly generated number: int randomNumber = new randomGenerator.nextInt(3); fact = randomNumber + ""; //update screen with dynamic fact

            mFactTextView.setText(fact);
        }
    };

2 Answers

Kourosh Raeen
Kourosh Raeen
23,733 Points

Do you have the following import statement?

import java.util.Random
David Hume
David Hume
10,334 Points

I found my mistake. Typo. Had an extra "new" in code.