Tim Cooke wrote:You cannot be certain because you don't know what the method s(B b) in class A does with the reference to object b that's passed into it. It may pass that reference on to something else that keeps hold of it, or maybe it doesn't. You just don't know.
Make sense?
Junilu Lacar wrote:
L Hasan wrote:A constructor is a class method that has no return type.
That is incorrect. Yes, a constructor looks like a method that doesn't have a return type. However, constructors are not methods, they are not considered members of the class, and they are not inherited nor do they participate in polymorphism.
See these articles:
http://www.dummies.com/programming/java/how-to-use-a-constructor-in-java/
http://www.javaworld.com/article/2076204/core-java/understanding-constructors.html
.It's called a constructor, which is a special type of method... and there's no return type.
Campbell Ritchie wrote:What a nice post You explained what I meant better than I could have.
Except you wroteNever use == true , or == false.. . . if(canInit == true) . . .
I have written about that many times. It is very error‑prone.
Use
if (b) ...
or
if (!b) ...
instead.