Java System類兩個(gè)常用方法代碼實(shí)例
1.System.currentTimeMills():得到當(dāng)前時(shí)間距離時(shí)間原點(diǎn)的毫秒數(shù),返回值是Long類型的整數(shù)。
代碼演示:
public class Demo4 { public static void main(String[] args) { long l = System.currentTimeMillis(); System.out.println(l); }}
運(yùn)行結(jié)果:
2.System.arrayCopy(src,srcpos,des,despos,length):將原數(shù)組src中srcpos位置及其后面length長度的數(shù)復(fù)制給目標(biāo)數(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個(gè)數(shù)(8,5)復(fù)制到數(shù)組b索引為2的位置上 System.arraycopy(a,3,b,2,2); System.out.println(Arrays.toString(b)); }}
運(yùn)行結(jié)果:
注意:
(1)目標(biāo)數(shù)組原來位置上的數(shù)直接被覆蓋了。
(2)數(shù)組索引從0開始。
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. JavaWeb Servlet中url-pattern的使用2. jsp中sitemesh修改tagRule技術(shù)分享3. asp(vbscript)中自定義函數(shù)的默認(rèn)參數(shù)實(shí)現(xiàn)代碼4. React優(yōu)雅的封裝SvgIcon組件示例5. 輕松學(xué)習(xí)XML教程6. php網(wǎng)絡(luò)安全中命令執(zhí)行漏洞的產(chǎn)生及本質(zhì)探究7. ASP刪除img標(biāo)簽的style屬性只保留src的正則函數(shù)8. JSP servlet實(shí)現(xiàn)文件上傳下載和刪除9. ASP基礎(chǔ)知識(shí)VBScript基本元素講解10. 詳解瀏覽器的緩存機(jī)制
