+ 1
How can I randomize values in table with 50 elements in Java?
I have loop with 50 elements (double) and i want add simply to each [ ] value from 0 to 10
6 Réponses
+ 2
You can of course save the set of random numbers in a array i.e.:
public class MultidimensionalArrayExample {
public static void main(String[] args) { // creating and initializing two dimensional array with shortcut syntax
double[][] arr = { { 1, 2 }, { 3, 4, 5 } };
for (int i = 0; i < arr.length; i++) { for (int j = 0; j < arr[i].length; j++)
{ System.out.print(arr[i][j] + " "); } System.out.println(""); }}}
+ 2
import java.util.Random;
public class Example {
public static void main(String[] args) {
Random rnd = new Random(); // creating Random object
System.out.println(rnd.nextDouble()); // displaying a random double value between 0.0 & 1.0
}
}
+ 2
Ja Play Thanks again bro ❤️
+ 1
Thanks a lot Ja Play
0
Calviղ Sorrry mate, i forgot write my question its about Java
but thank u for ur time