There is a parameter which is reference type, and can it receive other reference type? for instance, there is a code below
fr = new FileReader("d:\\test.txt");
br = new BufferedReader(fr);
the BufferedReader class receives FileReader type but I see in the JAVA API
BufferedReader(Reader in)
receives Reader type.
I know Reader class is abstract but it doesn't give me a clue. How is getting other types of reference as a parameter possible?
FileReader
is a subclass of InputStreamReader
, which is a subclass of Reader
. That said, all public methods and variables from Reader
are available in FileReader
.