What will 10.5.3 example print
Posted: Mon Oct 21, 2019 12:26 pm
From OCP Oracle Certified Professional Java SE 11 Programmer I Exam Fundamentals 1Z0-815: Study guide for passing the OCP Java 11 Developer Certification Part 1 Exam 1Z0-815 (English Edition) pages 235 and 237:
...
ic.printCount();
new InstanceCounter(). printCount();
System.out.println( InstanceCounter.printCount() +" "+ InstanceCounter.count);
...
will print:
1
2
2 2
I understand that first and second line the constructor is executed but in the last line it is not executed, right?
...
ic.printCount();
new InstanceCounter(). printCount();
System.out.println( InstanceCounter.printCount() +" "+ InstanceCounter.count);
...
will print:
1
2
2 2
I understand that first and second line the constructor is executed but in the last line it is not executed, right?