Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Subclassing both InputStream and OutputStream

Tags:

java

Can a Java class subclass both InputStream and OutputStream?

I would like to be able to extend both of these classes if it is possible.

like image 414
Mathew Boulton Avatar asked Aug 28 '26 02:08

Mathew Boulton


1 Answers

Both InputStream and OutputStream are classes (not interfaces). Java doesn't support multiple inheritance, so it is not possible to subclass them directly.

However, by using composition you can have behaviours from these two classes in one class.

like image 114
Michal Kordas Avatar answered Aug 30 '26 15:08

Michal Kordas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!