方法3

10.8

Java方法练习:

自方法:随机数生成:

代码部分:

package lianxi;
import javax.swing.JOptionPane;
public class bo {
public static void main(String[] args) {
int value;
String output = "";

for ( int i = 1; i <= 20; i++ )
{
value = 1 + (int) ( Math.random() * 6 );
output += value + " ";

if ( i % 5 == 0 )
output += "\n";
}

JOptionPane.showMessageDialog( null, output,
"20 Random Numbers from 1 to 6",
JOptionPane.INFORMATION_MESSAGE );

System.exit( 0 );
}

运行结果:


}

原文地址:https://www.cnblogs.com/092e/p/14142476.html