System classes in Java
Most common to System.out.println ();
The system class defined as public final class System extends object{} contains several useful class fields and methods, with the keyword final decoration, which indicates that this class cannot be inherited by another class.
It is constructed as private system{} (the construction method is privatized and cannot be instantiated externally).
There are three properties in System: In,out,err;
1.private final static InputStream in=null;
2.private final static PrintStream out=null;
--Out for class PrintStream type println () is the method in PrintStream. Out is final and static modified constants, so you can call the Out property with system, and then call the println () method.
3.private final static PrintStream err=null;
Several methods in the System:
The methods in System are all static decorated and can be called directly with the class name, such as System.getproperties ();
1,public static Properties getProperties () {} system.getproperties (). List (System.out); --Determines the current system properties.
2,public static string GetProperties (String key) {} system.getproperty (string key); -Gets the system properties specified by the current key.
3,public Static Long Currenttimemillis () {} system.currenttimemillis (); --Returns the current time in milliseconds.
public class s{public static void main (string[] args) { long starttime=system.currenttimemillis () ; int a=0; for (int i=0;i<1000000000;i++) { a+=i;} long endtime=system.currenttimemillis (); System.out.println ("performed this program with" + (Endtime-starttime) + "milliseconds. "); }}
------------> Output is: It took 380 milliseconds to execute the program.
4,public static void Arraycopy (object src, int srcpos, object dest, int destpos, int length) {} Copies the array from the specified source array to the target array from the specified point Fixed position.
public class s{public static void main (string[] args) { int[] a=new int[]{1,2,3,10,20,30,4,5,6}; Int[] b=new int[3]; System.arraycopy (a,3,b,0,3); for (int i=0;i<b.length;i++) {System.out.print (b[i]+ "");}}
-------------> Output: Ten------> A for array A, 3 for a array of coordinates (TEN), B for array b,0 to represent the coordinates of the B array 0,3 for the length of the copy.
Java System Class Learning notes