• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
C Selberg
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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.
 
Roel De Nijs
Sheriff
Posts: 10763
148
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • 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
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!