随机生成double二维数组的源程序
/* 本文出自 51CTO.COM技术博客* Created on 2006-6-21 * * TODO To change the template for this generated file go to * Window - Preferences - Java - Code Style - Code Templates */ package com.tiantian; import java.util.Random; //import java.math.*; /** * @author Administrator * * TODO To change the template for this generated type comment go to Window - * Preferences - Java - Code Style - Code Templates */ public class RandomArray { public static double[][] GetArray(int a, int b) { double num = 0; Random random = new Random(); int number = random.nextInt(100); int i = 10; int j = 10; double[][] a2; if ((a != 0) && (b != 0)) a2 = new double[a]; else a2 = new double[1][1]; for (i = 0; i < a2.length; i++) for (j = 0; j < a2[i].length; j++) { num = random.nextDouble(); a2[i][j] = num; } return a2; } public static void main(String[] args) { //Random random = new Random(); //double num = random.nextDouble(); //System.out.println(number); double[][] a = RandomArray.GetArray(10, 10); for (int i = 0; i < a.length; i++) for (int j = 0; j < a[i].length; j++) { System.out.println(a[i][j]); } } } |


amyhang
博客统计信息
热门文章
最新评论
友情链接