产生随机数代码

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+" 和为"+k;
JOptionPane.showMessageDialog( null, x,
"Demonstrating String Class Constructors",
JOptionPane.INFORMATION_MESSAGE );

}

}

原文地址:https://www.cnblogs.com/LJT666/p/5492659.html