Java System類兩個常用方法代碼實例
1.System.currentTimeMills():得到當前時間距離時間原點的毫秒數(shù),返回值是Long類型的整數(shù)。
代碼演示:
public class Demo4 { public static void main(String[] args) { long l = System.currentTimeMillis(); System.out.println(l); }}
運行結(jié)果:
2.System.arrayCopy(src,srcpos,des,despos,length):將原數(shù)組src中srcpos位置及其后面length長度的數(shù)復制給目標數(shù)組des的despos位置。
代碼演示:
import java.util.Arrays;public class Demo4 { public static void main(String[] args) { int[] a={3,7,1,8,5}; int[] b={11,2,16,7,9,0}; //把數(shù)組a索引為3的位置往后2個數(shù)(8,5)復制到數(shù)組b索引為2的位置上 System.arraycopy(a,3,b,2,2); System.out.println(Arrays.toString(b)); }}
運行結(jié)果:
注意:
(1)目標數(shù)組原來位置上的數(shù)直接被覆蓋了。
(2)數(shù)組索引從0開始。
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. ASP常用日期格式化函數(shù) FormatDate()2. chat.asp聊天程序的編寫方法3. CSS 使用Sprites技術(shù)實現(xiàn)圓角效果4. phpstudy apache開啟ssi使用詳解5. 詳解瀏覽器的緩存機制6. ASP中if語句、select 、while循環(huán)的使用方法7. 怎樣才能用js生成xmldom對象,并且在firefox中也實現(xiàn)xml數(shù)據(jù)島?8. HTML中的XML數(shù)據(jù)島記錄編輯與添加9. 利用FastReport傳遞圖片參數(shù)在報表上展示簽名信息的實現(xiàn)方法10. 推薦一個好看Table表格的css樣式代碼詳解
