This question is an exact duplicate of:
- Decorator pattern java.io.reader 1 answer
Does BufferedReader
use the decorator pattern?
BufferedReader
is a subclass of Reader
.
- But
BufferedReader
has only one fieldlock
with typeObject
, instead of a field of typeReader
. So it doesn't seem to use the decorator pattern. -
But
BufferedReader
has constructorsBufferedReader(Reader in)
andBufferedReader(Reader in, int sz)
, both having an argument of typeReader
, which seems to me thatBufferedReader
should have a field with typeReader
and thereforeBufferedReader
should follow the decorator pattern. Why do the constructors have an argument of typeReader
, if it doesn't have a field of typeReader
?Thanks.
Aucun commentaire:
Enregistrer un commentaire