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

Java Do While Loops

Lucas Frixione
Lucas Frixione
1,332 Points

Okay, so i have a doubt about that Random

When he says lucky.nextBoolean() he is randomly alterning in between true and false because thats a method of the Random class? and if yes wouldn't he need to import a library like he did when when we were using de IO library?

2 Answers

Seth Kroger
Seth Kroger
56,413 Points

There's a "blink and you'll miss it" spot at 1:15 where he's at the top of the code before he scrolls down. You'll see an import java.util.Random; there already.

Wan Faruq Adiputra
Wan Faruq Adiputra
2,938 Points

Yes he is randoming the boolean variable lucky. As Seth Kroger state it you can see at 1:15 random library is included. You can also check his final code under teachers note -> workspace snapshots -> ending point -> MiniGolf.java.