---------------------- <a href="http://www.itheima.com" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" target="blank">ASP.Net+Unity開發</a>、<a href="http://www.itheima.com" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" target="blank">.Net教育訓練</a>、期待與您交流! ----------------------
1.System類
一、功能與用途
System類是jvm啟動時加載和作業系統相關的預設資訊并以鍵值對的形式放到map中。
二、特點
1.它是用final修飾類,是以不能被繼承。
2.它對外沒有提供構造器類,是以隻能使用static關鍵字,調用類成員屬性和行為。
三、常用屬性和方法
(1)常用屬性
System.in 标準輸入流,即鍵盤錄入的值。
System.out 标準輸出流,即console控制台。
(2)常用方法
gc(), 系統運作時垃圾回收器。
currentTimeMillis() ,系統目前時間,機關:毫秒。
getProperties(),傳回Properties對象,Properties又是HashTable的子類,是以系統相關資訊是鍵值對的形式存儲到Properties對象中。
getProperty(String key),通過key或者系統的值,如getProperty(“os.name”)作業系統名稱。
setProperties(Properties props),設定Properties對象。
setProperty(String key,String value) ,用實際鍵和值來設定系統資訊。
2.Runtime類
它是Java運作時環境對象,每一個Java應用程式都有一個運作時環境。即一個Runtime執行個體,在這類中無對外可通路的構造函數,但提供了可獲得該類對象的方法getRuntime()且為靜态的,說明它是單例模式的典型應用。
該類中常用的方法說明:
getRuntime(),獲得一個Runtime對象,對于每個Java應用程式有且僅有一個。
gc(),垃圾回收器,通常由jvm自動調用,不需要程式員考慮。
exec(String command),作業系統中console界面執行的指令。
---------------------- <a href="http://www.itheima.com" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" target="blank">ASP.Net+Unity開發</a>、<a href="http://www.itheima.com" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" target="blank">.Net教育訓練</a>、期待與您交流! ----------------------
詳細請檢視:<a href="http://www.itheima.com" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" target="blank">www.itheima.com</a>