A brief introduction to the use of the Java System class

java.lang.SystemClass 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.
  • public static void arraycopy(Object src, int srcPos, Object dest, int destPos, int length): Copy the data specified in the array to another array.

currentTimeMillis method

In fact, currentTimeMillis method is to get the millisecond time difference between the current system and at 00:00 on January 1st, 1970 points

System.out.println(System.currentTimeMillis());  
//1584589108112

arraycopy method

  • 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:

Parameters No. parameter name Parameter Type Parameter Meaning
1 src Object Source array
2 srcPos int Source array index start position
3 hand Object Target array
4 destPos int Destination array index of the starting position
5 length int Copy number of elements

Demo:

  long l = System.currentTimeMillis();
  int[] array = {1,2,3,4,5};
  int[] copyArray = new int[5];
  System.arraycopy(array,0,copyArray,0,5);
  for (int i = 0; i < copyArray.length; i++) {
      System.out.print(copyArray[i]);
  }
  //12345
Published 26 original articles · won praise 5 · Views 1909

Guess you like

Origin blog.csdn.net/weixin_43840862/article/details/104963813