import java.lang.System.out;//error
Why is the above statement at the beginning of the program wrong?
The following sentence is correct regardless of whether it has static or not. Why is this?
import static java.lang.System.*;
as the picture shows:
First you need to understand the newly added feature in 1.5 called static import
The so-called static import simply means importing static variables and methods
The format is import static package name.class name.static property|static method
Let me show you the source code: out is a static variable modified with static, so if you don’t add static when importing the package, an error will be reported
The System class only has static-modified properties or methods, so you don’t need to add static.