java.lang.System.out has been already imported, why 'out' is still used in out.println(MAX_VALUE) rather than println(MAX_VALUE)
You import the static member of the class using "import static"; out is static member of the class System. And out is object of PrintStream, using out you access the public methods like print(...), println() of the PrintStream class.
Joined: Dec 07, 2004
How do you import a static method(in this case Integer.tohexString()) rather than using * in import statement?
Originally posted by jibs parap: How do you import a static method
The same way you use to import a static variable.
Joined: Aug 05, 2006
Thanks for the clarification. Yes we can import static variable or method using static import. To import all the static members [Variables+methods] use pkg.classname.* For example to import all the static members of Arrays clas import static java.util.Arrays.*;
To import static method sort() use import static java.util.Arrays.sort;
To import static variable import static classname.staticVariableName;