The moose likes Beginning Java and the fly likes - Abstract method? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark " - Abstract method?" Watch " - Abstract method?" New topic
Author - Abstract method?

Thomas Markl
Ranch Hand

Joined: Mar 08, 2001
Posts: 192
Why are these programs the same?
Why is it possible to say InputStream in = Is an object which can be referenced?

P.S: I found a good posting on read() called "Abstract method read()" but I don't understand it. So i post this question.
[ Edited to preserve formatting using the [code] and [/code] UBB tags. It'd be nice if Thomas would start doing this all by himself -ds ]
[ July 30, 2002: Message edited by: Dirk Schreckmann ]
Neil Laurance
Ranch Hand

Joined: Jul 18, 2002
Posts: 183
The class java.lang.System class contains the following 3 public constants:
public static final err;
public static final in;
public static final out;
What this means is that is a type of InputStream. In fact, it will be a concrete subclass of this abstract class. However, you can just use the methods of InputStream, and the underlying methods will be called due to polymorphism. Similarly, you can create an alias to the InputStream handle with the code:
InputStream in =;
What this means is that in and are both handles to the same underlying object.
Hope this hasn't confused you more...
I agree. Here's the link:
subject: - Abstract method?
It's not a secret anymore!