Results 1 to 4 of 4
  1. #1
    Ndhappy is offline Member
    Join Date
    May 2013
    Posts
    2
    Rep Power
    0

    Default Understanding Java Source

    I'm quite new to Java and object-oriented programming in general. I have written a small application and I'm looking to expand my understanding. I hate even asking these questions because they feel so basic but I cannot find answers on Google or using the search function on these forums.

    What I'm trying to do is understand some basic input reading. I've started with the InputStream.java; around line 45 in the source is:

    Java Code:
    public abstract class InputStream implements Closeable {
    So I hop over to Closeable.java to understand what it is doing and I find it to be quite bare. It says it extends AutoCloseable so I check that source and it is even more bare! For the life of me, I cannot find where either of these two files do any work whatsoever.

    My question is this (for clarity, I'm just questioning a single file)...how does Closeable.java turn this:

    Java Code:
    package java.io;
    import java.io.IOException;
    public interface Closeable extends AutoCloseable {
        public void close() throws IOException;
    }
    into anything remotely useful? To my inexperienced eyes, it appears to do nothing at all!

    Thanks in advance!

    Edit: To any potential responders, don't feel like you need to explain every detail, I'm perfectly happy looking definitions up if need-be. I'm a newbie but I'm not lazy :)

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default Re: Understanding Java Source

    Do you know what an Interface is and how it is used? Have a look at the tuorial: Interfaces (The Java™ Tutorials > Learning the Java Language > Interfaces and Inheritance)
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,016
    Rep Power
    20

    Default Re: Understanding Java Source

    They're interfaces.
    They simply say that anything implementing this interface will provide implementations of these methods.
    They're a contract, and nothing more.
    It's the concrete classes that actually do the work.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  4. #4
    Ndhappy is offline Member
    Join Date
    May 2013
    Posts
    2
    Rep Power
    0

    Default Re: Understanding Java Source

    PhHein and Tolls, your responses are very much appreciated. I read "What Is An Interface" from the Oracle site and it served to further my confusion. The link provided and the brief response are more than enough to put me back on track.

    Thanks!

Similar Threads

  1. Replies: 5
    Last Post: 09-16-2011, 06:58 AM
  2. Replies: 6
    Last Post: 05-04-2011, 07:34 AM
  3. Need help understanding Java Sound
    By Fortu in forum New To Java
    Replies: 1
    Last Post: 12-26-2010, 03:08 AM
  4. Replies: 1
    Last Post: 05-19-2010, 07:45 AM
  5. python source to java source converter?
    By conor147 in forum New To Java
    Replies: 0
    Last Post: 01-15-2010, 05:14 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •