Tiantian said to use System.out.println for output, so I have a small question to ask, is out a variable or an internal class? Large and systematic knowledge is explained in detail in various topics. We cannot ignore these scattered knowledge points, otherwise it will be very embarrassing if we are asked such a simple question during the interview and cannot answer it.
System is a system class. In the java.lang package of JDK, it can be seen that it is also a core language of java. characteristic. The constructor of the System class is decorated with private and is not allowed to be instantiated. Therefore, the methods in the class are also static modified static methods.
public final static InputStream in; //标准输入流 public final static PrintStream out; //标准输出流 public final static PrintStream err; //标准错误流
It can be seen that out and in in System are not internal classes, but genuine field variables. out is the variable field modified by PrintStream's final static, which means it can call methods of the PrintStream class. Println is an output method of PrintStream, so we usually use System.out.println() to output content on the console.
public static void main(String[] args) { int[] arr1 = { 0, 1, 2, 3, 4 }; int[] arr2 = { 9, 9, 9, 9, 9 }; System.arraycopy(arr1, 2, arr2, 0, 3); arr1[3] = 8; for (int i = 0; i < 5; i++) System.out.print(arr2[i] + " "); //2 3 4 9 9 }
The arraycopy method has five parameters, which are the array to be copied, the starting position to be copied, the array to copy to, the starting position of the array to copy, and the copy to the end of this array. This method is similar to copyOf and copyOfRange in Arrays. It has more parameters and can be used if necessary.
I won’t give an example here, the currentTimeMillis method and the getTime method in the Date class It's exactly the same, if you just need milliseconds, such a call is also very convenient. However, it should be noted that currentTimeMillis does not directly get the result of getTime. currentTimeMillis is a local method that returns the time of the operating system. Since the minimum accuracy of the time of some operating systems is 10 milliseconds, this method may cause some deviations. .
We call this method and enter the key ## in the parameter #StringGet system properties.
Key | Description of related values |
---|---|
Java Runtime Environment Version | |
Java Runtime Environment Vendor | |
Java Provider URL | |
Java | InstallationDirectory |
Java Virtual Machine Specification Version | |
Java Virtual Machine Specification Supply Business | |
Java virtual machine specification name | |
Java virtual machine implementation version | |
Java virtual machine implementation vendor | |
Java virtual machine implementation name | |
Java runtime environment specification version | |
Java Runtime Environment Specification Vendor | |
Java Runtime Environment specification name | |
class.version | Java class format version number|
Java class path | |
List of paths to search | when loading the library |
Default temporary file path | |
To The name of the JIT compiler to use | |
The path to one or more extension directories | |
The name of the operating system | |
Architecture of the operating system | |
Operating system version | |
.separatorFile separator ( In UNIX systems it is "/") | |
Path separator (in UNIX systems it is ":") | |
Line separator ("/n" on UNIX systems) | |
user Account name | |
User’s home directory | |
user Current working directory |
The above is the detailed content of In-depth analysis of java-System system class. For more information, please follow other related articles on the PHP Chinese website!