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 trialRiya Prasannan
806 PointssetText
Is it ok to use it like this. It works this way too. Random randomGenerator = new Random(); int randomNumber = randomGenerator.nextInt(facts.length); factTextView.setText(facts [randomNumber]);
instead of randomGenerator = new Random(); int randomNumber = randomGenerator.nextInt(facts.length); String fact = facts [randomNumber]; factTextView.setText(fact);
2 Answers
Atul Rai
872 PointsIt doesn't matter which way you choose as both the ways are eventually the same thing.
Riya Prasannan
806 PointsThanks Atul.