The Boolean example is IMO not the best example for a factory method. As Boolean provides the two boolean values as immutable constants which are easier to use.
Also the parseBoolean (not parseValue) method returns a native boolean, which needs to be boxed. This is usually done via the Boolean#valueOf method, which will also return the constants.
You can see this quite nicely in the jshell:
Boolean.parseBoolean("true") == Boolean.TRUE
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
The Boolean example is IMO not the best example for a factory method. As Boolean provides the two boolean values as immutable constants which are easier to use.
Also the parseBoolean (not parseValue) method returns a native boolean, which needs to be boxed. This is usually done via the Boolean#valueOf method, which will also return the constants.
You can see this quite nicely in the jshell: