The classes java.io.Reader and java.io.InputStreamReader both have read methods with the exact same signature
public int read(char[] charbuf, int offset, int length) throws IOException
Now according to the java documentation the class java.io.FileReader inherits both these read() methods from both the above-mentioned classes.
Now as FileReader extends InputStreamReader which further extends Reader
(Reader <-- Inputstreamreader <-- FileReader)
and the read() has same signature in both classes, shouldn’t it have been that InputStreamReader overrode the read() from Reader and FileReader inherited that over-ridden method?? Or am i missing something here??
Also the two read()s inherited by FileReader have slightly different functionality (something about one blocks while waiting for input while the other doesn’t).
The method in
InputStreamReaderprovides the implementation for the abstract method inReader.FileReaderdoesn’t override that method any further; it just inherits the implementation fromInputStreamReader.Note that there are four signatures for read:
InputStreamReaderonly overrides the first two of these. Perhaps that’s what was confusing you?