Class System Overview
java.lang.System in class provides a number of static methods, you can get information or system-level operating system-related, in the API documentation System class, commonly used methods are:
- public static long currentTimeMillis (): returns the current time in milliseconds. In fact, currentTimeMillis method is to get the millisecond time difference between the current system and at 00:00 on January 1st, 1970 points
public class SystemDemo { public static void main (String [] args) { // get the current time value in milliseconds System.out.println (System.currentTimeMillis ()); // 1575800449598 } }
- public static void arraycopy (Object src, int srcPos, Object dest, int destPos, int length): copy the data specified in the array to another array. A copy operation of the array system-level, high performance. System.arraycopy method has five parameters, meaning respectively:
Package Demo05; Import java.util.Arrays; public class SystemArrayCopy { public static void main (String [] args) { / * the src - the source array. srcPos - start position (start index) in the source array. dest - the destination array. destPos - starting position of the target data. length - the number of array elements to be copied. Exercise: The first three in the src array elements are copied to three positions on the array dest before copying element: src array element [1,2,3,4,5], dest array element [6,7,8, 9,10] after copying elements: * / // definition of the source array int [] = {the src. 1, 2,. 3,. 4,. 5 }; //Define the target array int [] = {dest. 6,. 7,. 8,. 9, 10 }; System.out.println ( "before copying:" + of Arrays.toString (dest)); // Use the System class source arraycopy the first three elements of the array are copied to three positions on the target array System.arraycopy (the src, 0, dest, 0,. 3 ); System.out.println ( "after copying:" + of Arrays.toString (dest)) ; } }
The result of code execution