一、请看下面源代码,你发现了有什么特殊之处吗?
他们的参数类型不同,参数名相同——方法重载!!
二、随机整数
a,源代码
// RandomInt.java // Shifted, scaled random integers import javax.swing.JOptionPane; public class Random { public static void main( String args[] ) { int value; String output = ""; for ( int i = 1; i <= 1000; i++ ) { value = 1 + (int) ( Math.random() * 1000 ); output += value + " "; if ( i % 20 == 0 ) output += " "; } JOptionPane.showMessageDialog( null, output, "20 Random Numbers from 1 to 6", JOptionPane.INFORMATION_MESSAGE ); System.exit( 0 ); } }
b,结果