Java.lang System
1 Java.lang System介绍
java.lang.System 类包含一些有用的类字段和方法。它不能被实例化。通过系统提供的工具:
-
标准输出
-
错误输出流
-
标准输入和访问外部定义的属性和环境变量。
-
一种实用程序方法,用于快速复制数组的一部分。
-
加载文件和库文件的方法
2 Java.lang System声明
public final class System
extends Object
3 Java.lang System方法
4 Java.lang System案例1
package com.yiidian;
/**
* 一点教程网: http://www.yiidian.com
*/
import java.lang.*;
public class SystemArrayCopyExample1 {
public static void main(String[] args) {
String a[]= {"A","B","B","H","A","M"}; //source array
String b[]= {"S","H","U","N","U","L","L","J","A","D","O","N"}; //destination array
String src[],dest[];
int srcPos,destPos,length;
src=a;
srcPos=2;
dest=b;
destPos=3;
length=4;
System.out.print("Source array:");
for(int i=0;i<src.length;i++) {System.out.print(a[i]);}
System.out.println();
System.out.print("Destination array:");
for(int i=0;i<src.length;i++) {System.out.print(b[i]);}
System.out.println();
System.out.println("Source Position:"+srcPos);
System.out.println("Destination Position:"+destPos);
System.out.println("Length:"+length);
System.arraycopy(src, srcPos, dest, destPos, length); //use of arraycopy() method
System.out.println("Destination array after use of arraycopy()");
for(int i=0;i<b.length;i++)
{
System.out.print(b[i]);
}
}
}
输出结果为:
Source array:ABBHAM
Destination array:SHUNUL
Source Position:2
Destination Position:3
Length:4
Destination array after use of arraycopy()
SHUBHAMJADON
5 Java.lang System案例2
package com.yiidian;
/**
* 一点教程网: http://www.yiidian.com
*/
public class SystemCurrentTimeMillisExample2 {
public static void main(String[] args) {
System.out.println("Current time in millisecond");
System.out.println(System.currentTimeMillis()); //method of calling current time in millisecond
}
}
输出结果为:
Current time in millisecond
1532262046724
热门文章
优秀文章