Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Random;
- public class CreateArrayWithRandomNumbers {
- public static void main(String[] args) {
- double[][] matrix1 = new double[8][6];
- for (int i=0; i<matrix1.length; i++){
- for (int j=0; j<matrix1[i].length; j++){
- matrix1[i][j] = (int)(Math.random()*100);
- }
- }
- // OR
- double[][] matrix2 = new double[8][6];
- Random ran = new Random();
- for (int i=0; i<matrix2.length; i++){
- for (int j=0; j<matrix2[i].length; j++){
- matrix2[i][j] = ran.nextDouble();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment