The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
January 2001



This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.


Why does this code snippet work ??

Posted by John Dell'Oso on January 10, 2001 at 6:40 PM

I'm very interested in why the following snippet works .. I got this from a text called Java Bible ..

URL url;
InputStream in;
url = new URL("some url");
in = url.openStream()

I've go no problems with "url" .. my query really concerns "in". InputStream is an abstract class, so by rights it can't be instantiated. So what do we call "in", is it a variable, object reference, whatever ? Later on in the sample code, a method of the class InputStream is used as well like:

while ((numb = != -1) etc... etc ...

How is this possible ? "in" I think is not an object, so how can a message be sent in this way ?

Any insights into my (probably trivial) query would be appreciated.


John Dell'Oso


Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us