動手動腦感想

來源:互聯網
上載者:User

標籤:動手   static   個數   turn   span   mod   重載   int   shu   

 

動手動腦一:
public class suijishu{  private static final int N = 200;  private static final int LEFT = 40;  private static final int RIGHT = 10000;  private static long x0 = 1L;  private long a = 1103515245L;  private long c = 12345L;  private long m = 2147483648L;  private long rand ( long r )  {    r = ( r * a + c ) % m;//Xn+1=(aXn + c)mod m    return r;  }  private long little ( int a, int b, long rand )  {    return a + rand % ( b - a + 1 );  }  private void recursion ( int count, long rand )  {    if (count >= N)    {      return;    }    rand = rand (rand);    long r = little (LEFT, RIGHT, rand);    System.out.print (r + " ");    recursion (++count, rand);  }  public static void main ( String[] args )  {    suijishu re = new suijishu ();    re.recursion (0, x0);  }}

 

 

動手動腦二:

我發現同樣名稱的函數可以不同,這使得函數變得更全面,不同的參數類型可以自動調用相應的函數,即方法的重載。

滿足以下條件的兩個或多個方法構成“重載”關係:

(1)方法名相同;

(2)參數類型不同,參數個數不同,或者是參數類型的順序不同。

動手動腦感想

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.