码迷,mamicode.com
首页 > 其他好文 > 详细

产生随机数

时间:2015-11-02 23:03:51      阅读:180      评论:0      收藏:0      [点我收藏+]

标签:

package t9;

import java.util.Random;

import javax.swing.JOptionPane;

public class t9 {

public static void main(String[] args)
{


int []a=new int[10];
int i,k=0;
for(i=0;i<10;i++)
{
Random random1= new Random();
a[i]=random1.nextInt(100);
k=k+a[i];
}
String x=new String();
for(i=0;i<10;i++)
{
x=x+" "+a[i];
}
x=x+"\n和为"+k;
JOptionPane.showMessageDialog( null, x,
"Demonstrating String Class Constructors",
JOptionPane.INFORMATION_MESSAGE );

}

}

产生随机数

标签:

原文地址:http://www.cnblogs.com/love-xi/p/4931389.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!