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
BufferedReaderhas only one fieldlockwith typeObject, instead of a field of typeReader. So it doesn't seem to use the decorator pattern. -
But
BufferedReaderhas constructorsBufferedReader(Reader in)andBufferedReader(Reader in, int sz), both having an argument of typeReader, which seems to me thatBufferedReadershould have a field with typeReaderand thereforeBufferedReadershould 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