Java System類兩個常用方法代碼實(shí)例
1.System.currentTimeMills():得到當(dāng)前時間距離時間原點(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個數(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開始。
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. python實(shí)現(xiàn)讀取類別頻數(shù)數(shù)據(jù)畫水平條形圖案例2. Java 基于UDP協(xié)議實(shí)現(xiàn)消息發(fā)送3. Python編寫nmap掃描工具4. php5.6不能擴(kuò)展redis.so的解決方法5. python 爬取嗶哩嗶哩up主信息和投稿視頻6. 關(guān)于HTML5的img標(biāo)簽7. python 如何停止一個死循環(huán)的線程8. CSS3實(shí)現(xiàn)動態(tài)翻牌效果 仿百度貼吧3D翻牌一次動畫特效9. ASP.NET MVC前臺動態(tài)添加文本框并在后臺使用FormCollection接收值10. PHP獲取時間戳等相關(guān)函數(shù)匯總
