(1)java生成随机1000个整数
package
com.s.x;
//输入10个随机数,并显示最大值,最小值
import
java.util.*;
public
class
Value {
public
static
void
main(String[] args) {
int
a[]=
new
int
[
100
];
//定义一个数组
for
(
int
i=
0
;i<
100
;i++){
a[i]=(
int
)(Math.random()*
10
);
}
for
(
int
i=
0
;i<
100
;i++){
a[i]=(
int
)(Math.random()*
10
);
if
(i%
10
==
0
){
System.out.println(
""
);
}
System.out.print(a[i]);
}
}
}
(2)
// MethodOverload.java
// Using overloaded methods
public class MethodOverload {
public static void main(String[] args)
{
System.out.println("The square of integer 7 is " + square(7));
System.out.println("\nThe square of double 7.5 is " + square(7.5));
}
public static int square(int x)
{
return x * x;
}
public static double square(double y)
{
return y * y;
}
}
(3)动手动脑
对方法的重载