Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817
Moderator: admin
javiut
Posts: 37 Joined: Fri Oct 19, 2012 10:48 am
Location: Venezuela
Contact:
Post
by javiut » Sun Apr 05, 2020 8:02 am
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
Best regards.
admin
Site Admin
Posts: 10045 Joined: Fri Sep 10, 2010 9:26 pm
Contact:
Post
by admin » Mon Apr 06, 2020 12:28 am
You are right. It should be :
InstanceCounter.printCount()+" "+System.out.println(InstanceCounter.count);
Added to errata.
thank you for your feedback!
If you like our products and services, please help us by posting your
review here .
javiut
Posts: 37 Joined: Fri Oct 19, 2012 10:48 am
Location: Venezuela
Contact:
Post
by javiut » Mon Apr 06, 2020 5:10 am
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);
admin
Site Admin
Posts: 10045 Joined: Fri Sep 10, 2010 9:26 pm
Contact:
Post
by admin » Mon Apr 06, 2020 5:33 am
Right! What was I thinking!!
Updated.
Paul.
If you like our products and services, please help us by posting your
review here .
Users browsing this forum: No registered users and 45 guests