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.
Non-instantiable System class
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.
Field
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.
Commonly used methods in System
arraycopy—— ArrayCopy
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.
currentTimeMillis——Return the number of milliseconds
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. .
getProperty——Get the system attribute
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!

Start Spring using IntelliJIDEAUltimate version...

When using MyBatis-Plus or other ORM frameworks for database operations, it is often necessary to construct query conditions based on the attribute name of the entity class. If you manually every time...

Java...

How does the Redis caching solution realize the requirements of product ranking list? During the development process, we often need to deal with the requirements of rankings, such as displaying a...

Conversion of Java Objects and Arrays: In-depth discussion of the risks and correct methods of cast type conversion Many Java beginners will encounter the conversion of an object into an array...

Solutions to convert names to numbers to implement sorting In many application scenarios, users may need to sort in groups, especially in one...

Detailed explanation of the design of SKU and SPU tables on e-commerce platforms This article will discuss the database design issues of SKU and SPU in e-commerce platforms, especially how to deal with user-defined sales...

How to set the SpringBoot project default run configuration list in Idea using IntelliJ...


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools