How can I randomize values in table with 50 elements in Java? | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 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

12th Jul 2020, 10:00 AM
Norbert Gościński
Norbert Gościński - avatar
6 Respuestas
+ 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(""); }}}
12th Jul 2020, 7:48 PM
JaScript
JaScript - avatar
+ 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 } }
12th Jul 2020, 10:27 AM
JaScript
JaScript - avatar
+ 2
Ja Play Thanks again bro ❤️
12th Jul 2020, 7:50 PM
Norbert Gościński
Norbert Gościński - avatar
+ 1
Thanks a lot Ja Play
12th Jul 2020, 10:31 AM
Norbert Gościński
Norbert Gościński - avatar
0
Calviղ Sorrry mate, i forgot write my question its about Java but thank u for ur time
12th Jul 2020, 10:05 AM
Norbert Gościński
Norbert Gościński - avatar