Java System類

來源:互聯網
上載者:User

標籤:logs   垃圾   ++   end   靜態方法   pack   數組   目標   屬性   

 1 package demo04; 2  3 //因為構造方法被private修飾,System類不能建立對象,但是可以通過類名訪問其靜態方法 4 public class SystemDemo { 5     public static void main(String[] args) { 6         //static long currentTimeMillis() 返回以毫秒為單位的目前時間  7          8         //擷取程式已耗用時間 end-start 9         long start = System.currentTimeMillis();10         for (int i = 0; i < 10000; i++) {11             System.out.println(i);12         }13         long end = System.currentTimeMillis();14         System.out.println(end-start);15         16         //static void gc() 運行記憶體回收行程17         System.gc();18         19         //static Properties getProperties() 確定當前的系統屬性 20         System.out.println(System.getProperties());21         22         //static void arraycopy(Object src, int srcPos, Object dest, int destPos, int length) 23         //(源數組,起始位置,目標數組,目標數組起始位置,複製數組元素個數)從指定源數組中複製一個數組,複製從指定的位置開始,到目標數組的指定位置結束 24         int[] src = {1,2,3,4,5,6};25         int[] dest = {7,8,9};26         System.arraycopy(src, 1, dest, 0, 2);27         //[2,3,9]28         for (int i = 0; i < dest.length; i++) {29             System.out.println(dest[i]);30         }31         32         //static void exit(int status) 終止當前正在啟動並執行 JAVA 虛擬機器 33         System.exit(0);34         System.out.println("這裡不會執行");35     }36 }

 

Java System類

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.