• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Incorrect statement on page 552, Chapter 10 (K&B7)

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Currently:
If getInstance() weren't public, we would still have a singleton. However, it wouldn't be as useful because only static methods of the class Show would be able to use the singleton.
Correct:
If getInstance() weren't public, we would still have a singleton. However, it wouldn't be as useful because only static methods of the package would be able to use the singleton.
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi C Selberg,

First of all, a warm welcome to CodeRanch!

C Selberg wrote:Currently:
If getInstance() weren't public, we would still have a singleton. However, it wouldn't be as useful because only static methods of the class Show would be able to use the singleton.


That's indeed an incorrect statement and should be added to the errata overview.

C Selberg wrote:Correct:
If getInstance() weren't public, we would still have a singleton. However, it wouldn't be as useful because only static methods of the package would be able to use the singleton.


But that statement is incorrect as well I think the correct statement should be: If getInstance() weren't public, we would still have a singleton. However, it wouldn't be as useful because only methods of the package would be able to use the singleton.

Because instance methods can access static methods without any problem. So every method (instance or static) in the same package will be able to access the getInstance() method.

Hope it helps!
Kind regards,
Roel
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic