• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Inheritance or something else?

 
Ranch Hand
Posts: 48
Netbeans IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I encountered this line of code:



Now, my question is: how is it possible that it's using FileReader class as an argument to the constructor? According to Java 7 API, the constructor for BufferedReader class is BufferedReader(Reader in), i.e. my understanding is that it should have an object of type Reader or Reader's subclasses, and FileReader is not even a subclass of Reader. How is this possible?

Thank you.
 
Sheriff
Posts: 5555
326
IntelliJ IDE Python Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
FileReader is a subclass of InputStreamReader which is a subclass of Reader.
 
Bartender
Posts: 4568
9
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Click on one of the FileReader links in these posts, and at the top of the Javadoc page you can see the complete inheritance hierarchy.
 
Rod Taylor
Ranch Hand
Posts: 48
Netbeans IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Cooke wrote:FileReader is a subclass of InputStreamReader which is a subclass of Reader.



I see now that it doesn't need to be a direct subclass, i.e. a FileReader "is" a Reader by indirect inheritance.


Matthew Brown wrote:Click on one of the FileReader links in these posts, and at the top of the Javadoc page you can see the complete inheritance hierarchy.



Somehow I missed this!?? Thanks!
 
reply
    Bookmark Topic Watch Topic
  • New Topic