Page 1 of 1

[HD Pg 192, Sec. 8.3.3 - accessing-static-members-from-the-same-class]

Posted: Fri Feb 15, 2019 10:01 pm
by Username987654

Code: Select all

new InstanceCounter();
new InstanceCounter(); //accessing static method through an implicit reference to
an instance
new InstanceCounter().printCount(); //accessing count through the class name
System.out.println(InstanceCounter.count);
should be

Code: Select all

new InstanceCounter(); 
new InstanceCounter().printCount();//accessing static method through an implicit reference to an instance 
System.out.println(InstanceCounter.count);//accessing count through the class name
?

Re: [HD Pg 192, Sec. 8.3.3 - accessing-static-members-from-the-same-class]

Posted: Fri Feb 15, 2019 10:32 pm
by admin
Right. Added to the errata.
thank you for your feedback!

Re: [HD Pg 191, Sec. 8.3.2 - accessing-static-members-from-the-same-class]

Posted: Fri May 10, 2019 3:53 am
by natasci

Code: Select all

class TestClass{
	public static void main(String[] args){
		Foo f = null;
		f.baz();
	}
}
at page 190 baz() was declared as private static method in class Foo and therefore is not visible in TestClass

Re: [HD Pg 192, Sec. 8.3.3 - accessing-static-members-from-the-same-class]

Posted: Fri May 10, 2019 4:05 am
by admin
Right. Added to the errata.
thank you for your feedback!