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?
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.