java math.random
// Java program to demonstrate working
// of java.lang.Math.random() method
import java.lang.Math;
class Gfg2 {
// driver code
public static void main(String args[])
{
// define the range
int max = 10;
int min = 1;
int range = max - min + 1;
// generate random numbers within 1 to 10
for (int i = 0; i < 10; i++) {
int rand = (int)(Math.random() * range) + min;
// Output is different everytime this code is executed
System.out.println(rand);
}
}
}
public static double pow(double a, double b)
Parameter:
a : this parameter is the base
b : this parameter is the exponent.
Return :
This method returns ab.
Also in Java:
- java round double to 2 decimal places
- how to scan a character in java
- java hahmap
- java int to binary
- java random number
- java string reverse
- java split array into two
- arrays.aslist.add
- binary number input in int java
- full shutdown windows 10 cmd
- recursive function for fibonacci series in java javascript
- create java windows application
- print map java
- find a substring in a string java
- java replace element in list
- bufferedwriter doesn't write to file
- how to do for each in java
- remove part of string java
- android studio clear views of layout
- classes in java
- java iterate over list
- java doreturn void
- hashmap in java
- java create folder