Douglas Treadwell Douglas Treadwell - 1 year ago 80
Java Question

Why can't I import static java.lang.System.out.println?

It seems strange that I can't import static java.lang.System.out.println, when I can import static java.lang.Math.abs. Is there some reason behind this or am I doing something really stupid that I don't see at the moment? (Using Eclipse.)

Answer Source

Math is a class, on which abs is a static method. System.out is a static field rather than a class. So its println method isn't actually a static method, but an instance method on a static field.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download