1 Packagedemo04;2 3 //because the constructor method is private, the system class cannot create the object, but its static method can be accessed through the class name4 Public classSystemdemo {5 Public Static voidMain (string[] args) {6 //Static Long Currenttimemillis () returns the current time in milliseconds7 8 //Get program run time End-start9 LongStart =System.currenttimemillis ();Ten for(inti = 0; I < 10000; i++) { One System.out.println (i); A } - LongEnd =System.currenttimemillis (); -System.out.println (end-start); the - //static void GC () running the garbage collector - System.GC (); - + //static Properties GetProperties () determines the current system Properties - System.out.println (System.getproperties ()); + A //static void Arraycopy (object src, int srcpos, object dest, int destpos, int length) at //(source array, start position, target array, target array start position, copy array elements) copy an array from the specified source array, copy from the specified position, and end at the specified position in the destination array - int[] src = {1,2,3,4,5,6}; - int[] Dest = {7,8,9}; -System.arraycopy (SRC, 1, dest, 0, 2); - //[2,3,9] - for(inti = 0; i < dest.length; i++) { in System.out.println (Dest[i]); - } to + //static void exit (int status) terminates the currently running Java virtual machine -System.exit (0); theSystem.out.println ("will not execute here"); * } $}
Java System class