# Random class from book of nature of code

**URL:** <https://discourse.processing.org/t/random-class-from-book-of-nature-of-code/24354>\
**Category:** Beginners\
**Created:** [October 5, 2020, 11:52am UTC](https://discourse.processing.org/t/random-class-from-book-of-nature-of-code/24354 "2020-10-05T11:52:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sangshen](https://avatars.discourse-cdn.com/v4/letter/s/838e76/32.png) [@sangshen](https://discourse.processing.org/u/sangshen)\
**Post date:** [October 5, 2020, 11:52am UTC](https://discourse.processing.org/t/random-class-from-book-of-nature-of-code/24354/1 "2020-10-05T11:52:09Z")

</div>

> please format code with \</\> button \* [homework policy](https://discourse.processing.org/faq/#homework) \* [asking questions](https://discourse.processing.org/t/2147)

 ![Screen Shot 2020-10-05 at 19.48.58](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/e/e2f7e0b537e4d1a8b02adccd2ea9d23a0b04ae04.png)

there is a Random class showed on the book , but when I wrote code like this , the console showed me it cannot find a class named Random .

---

<div class="post-metadata">

**Author:** ![SomeOne](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/someone/32/8639_2.png) [@SomeOne](https://discourse.processing.org/u/SomeOne)\
**Post date:** [October 5, 2020, 12:40pm UTC](https://discourse.processing.org/t/random-class-from-book-of-nature-of-code/24354/2 "2020-10-05T12:40:28Z")

</div>

The hint is in the text. Random-class is in Java standard library and to use it you need to first import it, so add a line at very start `import java.util.Random;`

---

<div class="post-metadata">

**Author:** ![nking](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/nking/32/10780_2.png) [@nking](https://discourse.processing.org/u/nking)\
**Post date:** [October 5, 2020, 12:41pm UTC](https://discourse.processing.org/t/random-class-from-book-of-nature-of-code/24354/3 "2020-10-05T12:41:17Z")

</div>

You have to import the class first. Add `import java.util.Random;` at the top of your code.
