标签:load over 返回值 技术分享 auto 顺序 判断 int() out
1.设计思想:利用随机数产生公式,递归调用,输出一定数量的随机数。
2.源代码:
import java.util.Scanner;
public class Suiji_2 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner(System.in);
System.out.println("产生随机数数量:");
int m=in.nextInt();
System.out.println("input c:");
int c=in.nextInt();
suiji(m,c);
}
public static void suiji(int m,int c)
{
int a=1;
int x=(2^10000)-1;
for(int i=1;i<=m;i++)
{
a=((7^5)*a+c)%x;
System.out.print(a+" ");
if(i%10==0){System.out.println();}
}
}
}
3.程序截图:

1.程序代码:
1 // MethodOverload.java
2 package Testwenjian;
3 public class MethodOverload {
4
5 public static void main(String[] args) {
6 System.out.println("The square of integer 7 is " + square(7));
7 System.out.println("\nThe square of double 7.5 is " + square(7.5));
8 }
9
10 public static int square(int x) {
11 return x * x;
12 }
13
14 public static double square(double y) {
15 return y * y;
16 }
17 }
2.回答:
代码中的两个方法,方法名相同,但返回值类型和参数类型都不同,这就是方法的重载。
方法重载要求:
(1)方法名相同;
(2)参数类型不同,参数个数不同,或者是参数类型的顺序不同。
注意:方法的返回值不作为方法重载的判断条件!
标签:load over 返回值 技术分享 auto 顺序 判断 int() out
原文地址:http://www.cnblogs.com/lxy10375/p/7663608.html