Java import class system
•
Java
I have a question about class import. If you import a class, you seem to be able to call a method with a reduced line I don't understand the name of this operation. How can it be
For example:
Why this code
public class test { public static void main (String args[]) { System.out.print("Test"); } }
Can be replaced with
import static java.lang.System.out; public class test { public static void main (String args[]) { out.print("Test"); } }
What if you still have an object called "out"?
Thank you in advance
Solution
What happens is that the external class must be referenced by its full name:
String out = "Hello World"; java.lang.System.out.println(out);
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码