In java, why is Observable setChanged () protected?

If the java class, say classA, extends classB, it cannot extend Observable. But if the function setChanged()was publicly available and not protected, we can use composition to instantiate it Observablein classA.

Interestingly, the defense process was conceived setChanged().

+4
source share
1 answer

If setChangedsuch were publicly available, then everything could change them. Only the object itself should be able to modify them.

ClassA, ClassB, , , ClassA, Observable; ClassA, - , Observable ClassA.

Iterator.

+5

All Articles