From 7e1cf6d21abe1ddf551a604437be1c36e1be72b0 Mon Sep 17 00:00:00 2001 From: Martin Goik <goik@hdm-stuttgart.de> Date: Wed, 9 Nov 2016 15:12:28 +0100 Subject: [PATCH] Missing new Random() --- Doc/Sd1/statements.xml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Doc/Sd1/statements.xml b/Doc/Sd1/statements.xml index 95c46b147..4dca636b9 100644 --- a/Doc/Sd1/statements.xml +++ b/Doc/Sd1/statements.xml @@ -1884,11 +1884,15 @@ Congratulations! you won!</programlisting> <para>Regarding user input reading and random number generating methods please use the following recipe to get started:</para> - <programlisting language="java"> public static void main(String[] args) { - final short maxValueInclusive = 10; // Upper inclusive limit for selecting - // random - final int randomValue = // a random value ranging from 0 to - new <link + <programlisting language="java">package ... + +import java.util.Random; +... + public static void main(String[] args) { + final short maxValueInclusive = 10; // Upper inclusive limit for selecting + // random + final int randomValue = new Random() // a random value ranging from 0 to + .<link xlink:href="https://docs.oracle.com/javase/8/docs/api/java/util/Random.html#nextInt--">nextInt(maxValueInclusive + 1)</link>; // maxValueInclusive. final Scanner scan = new Scanner(System.in); -- GitLab