java-02-hands the Brain

Source: Internet
Author: User

1. Design idea: Use random number to produce formula, recursive call, output a certain number of random number.

2. Source code:

Import Java.util.scanner;public class Suiji_2 {public    static void Main (string[] args) {        //TODO auto-generated Me Thod stub        Scanner in = new Scanner (system.in);        System.out.println ("Generate random Number:");        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. Procedure:

1. Program code:

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 public     static int square (int x) {One         return x * x;12     }13 public     static Double square (double Y) {         return y * y;16     }17}

2. Answer:

The two methods in the code have the same method name, but the return value type and the parameter type are different, which is the overload of the method.

Method Overloading Requirements:

(1) The method name is the same;
(2) The parameter types are different, the number of parameters is different, or the order of the parameter types is different.

Note: The return value of the method is not used as a judging condition for the method overload!

java-02-hands the Brain

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.