1.
The system class is primarily used to obtain the system's property data.
Common methods of the system class:
arraycopy (object src, int srcpos, object dest, int destpos, int length) General
src-source array.
Srcpos-The starting position in the source array.
Dest-target array.
Destpos-The starting position in the target data.
Length-The number of array elements to copy.
Currenttimemillis () Gets the current system system. Focus
Exit (int status) exits the JVM if the parameter is 0 to exit the JVM normally, non 0 indicates an exception to exit the JVM. So so
GC () recommends that the JVM quickly start recycling garbage during garbage collection.
getenv (String name) gets the environment variable based on the name of the environment variable.
GetProperty (Key)
Finalize () If an object is reclaimed by the garbage collector, the object's Finalize () method is called first.
package com.yuanzijian;import java.util.arrays;import java.util.properties;class person{ String name;public person (String name) {this.name = name;} @Overridepublic void finalize () throws throwable {super.finalize (); System.out.println (this.name+ "was recycled..");}} Public class demo01 {public static void main (String[] args) {int[] srcarr = {10,12,14,16,19};//copies the Srcarr array elements into the Destarr array. int[] destarr = new int[4]; System.arraycopy (srcarr, 1, destarr, 0,4);//system.exit (0); &NBSP;//JVM exit: Note: 0 or non-0 data can exit the JVM. There is no difference for the user. System.out.println ("Elements of the target array:" + arrays.tostring (Destarr)); // 0 14 16 0SYSTEM.OUT.PRINTLN ("Current system time:" + system.currenttimemillis ()); SYSTEM.OUT.PRINTLN ("Environment variable:" +system.getenv ("Java_home")); for (int i = 0 ; i<4; i + +) {New perSon ("The Dog Doll" +i); System.GC (); //recommends starting the garbage collection period}properties properties = system.getproperties () immediately; // Gets all the properties of the system. Properties.list (System.out); String value = system.getproperty ("Os.name");//Gets the corresponding property value SYSTEM.OUT.PRINTLN according to the system's property name ("Current system:" +value );}}
Execution Results
Elements of the target array: [12,&NBSP;14,&NBSP;16,&NBSP;19] Current system time: 1464093543182 environment variable: C:\JAVA\jdk1.8.0_77 2 was recycled. The Dog Doll 3 was recycled. The Dog doll 0 was recycled. The Dog Doll 1 was recycled. -- listing properties --java.runtime.name=java (TM) SE Runtime Environmentsun.boot.library.path=c:\java\jdk1.8.0_77\jre\binjava.vm.version=25.77-b03java.vm.vendor=oracle corporationjava.vendor.url=http://java.oracle.com/path.separator=;java.vm.name=java hotspot (TM) 64-bit server vmfile.encoding.pkg=sun.iouser.script=user.country=cnsun.java.launcher=sun_ standardsun.os.patch.level=java.vm.specification.name=java virtual machine specificationuser.dir=g:\java\java0075java.runtime.version=1.8.0_77-b03java.awt.graphicsenv= Sun.awt.win32graphicsenvironmentjava.endorsed.dirs=c:\java\jdk1.8.0_77\jre\lib\endorsedos.arch= amd64java.io.tmpdir=c:\users\hnyua\appdata\local\templine.separator=java.vm.specification.vendor=oracle Corporationuser.variant=os.name=windows 10sun.jnu.encoding=gbkjava.library.path=C:\JAVA\jdk1.8.0_77\bin; c:\windows\su...java.specification.name=java platform api specificationjava.class.version= 52.0sun.management.compiler=hotspot 64-bit tiered compilersos.version=10.0user.home=c:\users\ hnyuauser.timezone=java.awt.printerjob=sun.awt.windows.wprinterjobfile.encoding=gbkjava.specification.version= 1.8user.name=yuanzijianjava.class.path=g:\java\java0075\binjava.vm.specification.version= 1.8sun.arch.data.model=64java.home=c:\java\jdk1.8.0_77\jresun.java.command= com.yuanzijian.demo01java.specification.vendor=oracle corporationuser.language=zhawt.toolkit= Sun.awt.windows.wtoolkitjava.vm.info=mixed modejava.version=1.8.0_77java.ext.dirs=c:\java\jdk1.8.0_77\jre \lib\ext; c:\wi...sun.boot.class.path=c:\java\jdk1.8.0_77\jre\lib\resources...java.vendor=oracle corporationfile.separator=java.vendor.url.bug=http://bugreport.sun.com/bugreport/sun.cpu.endian= LITTLESUN.IO.UNICODE.ENCODING=UNICODELITTLESUN.DESKTOP=WINDOWSSUN.CPU.ISALIST=AMD64 whenFront System: WINDOWS&NBSP;10
Java's 2.system.runtime class