0

Please I need the answers and little explan. what type of variable is x, what is numb in the code, and what is Random

Import Java.util.Random public class Maths{ public static void main(string[] args{ Random numb=new Random(System.in) System.out.print(''Generate a Number''); Int x = numb.nextInt();

22nd Jul 2017, 9:09 PM
wilson
1 Answer
+ 2
If any of this is confusing, you should start by learning the basics. For example, what is a constructor? and how can you call one? new Random(System.in); Is an invalid argument. So not sure what you're trying to do there. The only valid arguments for the constructors in the Random class is a long or nothing (default). Example/ new Random(); "Java" should also have a lower case 'j'. Int should also have a lowercase 'i' (before x). numb is an identifier. It's the name for the Random object you created. Random is a class in the util library. It contains many methods that allow the programmer to simulate randomness. nextInt() is a method in the Random class. It will return a pseudo-random int by the current seed. So, x will be the identifier for the int that gets a random number from the random class. From Oracle: "public int nextInt() Returns the next pseudorandom, uniformly distributed int value from this random number generator's sequence. The general contract of nextInt is that one int value is pseudorandomly generated and returned. All 232 possible int values are produced with (approximately) equal probability. The method nextInt is implemented by class Random as if by: public int nextInt() { return next(32); } Returns: the next pseudorandom, uniformly distributed intvalue from this random number generator's sequence"
22nd Jul 2017, 9:42 PM
Rrestoring faith
Rrestoring faith - avatar