Why do FilterInputStream and FilterOutputStream have different access modifiers in their constructors?

I just found that FilterInputStream (InputStream) has a different access modifier ( protected ) to this ( public ) FilterOutputStream (OutputStream)

Are there any technical reasons for this?

+5
source share
1 answer

This is a good place. Designers made a few mistakes when defining the Java API, and this inconsistency is apparently one of them. There is no reason why you would like to instantiate FilterOutputStream directly, so you should define a constructor with protected visibility.

Another question you can ask is why these classes are not abstract. There is no technical reason for this, as it was.

+3
source

All Articles