Page 1 of 1

Error on OCP 1Z0-815 BOOK Deshmukh, Hanumant Page 237

Posted: Sun Apr 05, 2020 8:02 am
by javiut
I dont know if i already made this but i dont see it on the errata.

In page 237

10.5.3 Accesing static members from the same class.

I see

Code: Select all

System.out.println(InstanceCounter.printCount()+" "+InstanceCounter.count);
But this is a compilation error because the printCount() method is void and cannot be inside a System.out.println :thumbup:

Best regards.

Re: Error on OCP 1Z0-815 BOOK Deshmukh, Hanumant Page 237

Posted: Mon Apr 06, 2020 12:28 am
by admin
You are right. It should be :
InstanceCounter.printCount()+" "+System.out.println(InstanceCounter.count);
Added to errata.
thank you for your feedback!

Re: Error on OCP 1Z0-815 BOOK Deshmukh, Hanumant Page 237

Posted: Mon Apr 06, 2020 5:10 am
by javiut
I think this would not work either.
InstanceCounter.printCount()+" "+System.out.println(InstanceCounter.count);
InstanceCounter.printCount() is void and you cannot append a value void.

This might work.
InstanceCounter.printCount();/*JUST LET THIS LINE PRINT ITSELF*/
System.out.println(InstanceCounter.count);

Re: Error on OCP 1Z0-815 BOOK Deshmukh, Hanumant Page 237

Posted: Mon Apr 06, 2020 5:33 am
by admin
Right! What was I thinking!!
Updated.
Paul.