I have the below code.
public static void main(String args[])
{
System s = null;
s.out.println("Hello");
}
I don't understand why the output is Hello though s is null. Could anyone help me to understand this?
System.out
is a static member of the type System
. This means that it doesn't require an instance to resolve; it only needs to know the type of s
which is known to be System
.
Being able to write s.out
is just a convenience for System.out
; most IDEs will throw a warning on this code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With