About Effective Java item 1.
A disadvantage of static factories is that you can't create subclasses of classes that don't have public or protected constructors.
In other words, I think you can't create a subclass of a class that has a private, package private constructor, but
Is this a drawback of the static factory?
Private, I think that package private constructor subclasses cannot be created in the first place (package private can be a subclass if they are the same package).
Is this not limited to the static factory? I wonder if there are any reasons listed here.
Answer # 1
Effective Java 3rd Edition is written as follows. It seems that the disadvantage in the 2nd Edition has been changed to the restriction (restriction) in the 3rd Edition ("only" has disappeared from the translation).
The main limitation of providing only static factory methods is that classes without public or protected constructors cannot be subclassed.
Restrictby providing only static factory methods, not "disadvantages of static factory methods". Immediately after it is written, "It's okay in fact," is not a fault.
- about javalangruntimeexception
- about java arrays
- about java inheritance
- i am a java beginner i have a question about an array
- java: i'm not sure about argslength
- question about java regular expression
- java - about socket communication timeout in android studio
- java - about android socket communication
- about java type conversion
- uncertainty about java
- about compiling class files in java dynamic web projects
- about java button creation
- java - i want to call a static method with a method reference
- java - about sql statement generation by doma
- java - about combining applications
- about java for loop
- java - about conversion of date type format
- java - about string conversion using the methods of the string class
- java - about error that cannot be resolved to a variable
- about passing by java reference
- python 3x - typeerror: 'method' object is not subscriptable
- python - you may need to restart the kernel to use updated packages error
- xcode - pod install [!] no `podfile 'found in the project directory
- vuejs - [vuetify] unable to locate target [data-app] i want to unit test to avoid warning
- android studio - emulator: dsound: could not initialize about the error message directsoundcapture
- android studio - unresolved reference comes out in kotlin
- mysql startup failed [error] innodb: the innodb_system data file 'ibdata1' must be writable
- django - oserror: [winerror 123] the file name, directory name, or volume label syntax is incorrect : '<frozen importlib_boot
- python - importerror: cannot import name md5 error cannot be resolved