🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #7245

Re: Interfaces and keyword THIS

#7245
From: Michael Rachow
Date: Thu, 05 Jul 2001 09:34
64 lines
2783 bytes
First the "physical" point of view.
Always there are references stored (for instances of clases).
So how complex an instance should be
all take the same kind of physical storage for their reference.
What an Interface expects from an object is that it had a certain
set of methodes implemented. So it uses the reference (here this)
and sends methods to this reference.
By that the Interfaces doesn't notice that there is a much more complex
object.
Because every Interface needs a class that implements it
all refrences that are stored as type Interface point to more complex
objects.

Hope I have recognized the reason why you had asked?!
Greetings
Michael


"Dick Gerrits" <dgerrits@wvm.nl> schrieb im Newsbeitrag
news:3b442242_2@dnews...
> Hello jbuilder.java.language people,
>
> Question about keyword "this". As I understood is the keyword this a
> reference to the current object.
> Suppose I extend a class from JApplet and implement the MouseListener
> interface like:
>
> public class Applet1 extends JApplet implements MouseListener{
> .....
> addMouseListener(this);
>
> public void MousePressed(MouseEvent e) {
>  ...}
>
> }
>
>
> To the method "addMouseListener" you can pass an object reference to
> "MouseListener" (the interface).
> (documentation method details -> public void
addMouseListener(MouseListener
> l)
> In many examples I see that you can pass the COMPLETE "current object" by
> using the keyword "this"
> (as in my example), but the method expects (only) a reference to a
> MouseListener interface.
>
> My question is:
> How does this work. What makes this possible ("this" implemented the
> interface MouseListener, but
> it is a lot more !).
>
> Thank you in advance for your explanation.
>
> Regards.
>
> B.V. Metaalwarenindustrie
> Witte van Moort
> Dick Gerrits
> dgerrits@wvm.nl
>
> -0-0-0-0-0-0-
>
>
Technical Details
Message-ID: <3b4438a6_1@dnews>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!news.tele.dk!193.174.75.178!news-fra1.dfn.de!news-koe1.dfn.de!RRZ.Uni-Koeln.DE!nntp.CS.Uni-Magdeburg.De!PeerFeed.KWeb.on.ca!dnews
References: <3b442242_2@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,91856323fbe3307a
X-Google-Attributes: gidf74b3,public
X-Google-ArrivalTime: 2001-07-05 02:56:33 PST
From: "Michael Rachow" <mrachow@BeraCom.de>
Newsgroups: borland.public.jbuilder.java.language
References: <3b442242_2@dnews>
Subject: Re: Interfaces and keyword THIS 
Date: Thu, 5 Jul 2001 11:34:58 +0200
Lines: 66
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4133.2400
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
NNTP-Posting-Host: 62.155.188.104
Message-ID: <3b4438a6_1@dnews>
X-Trace: dnews 994326694 62.155.188.104 (5 Jul 2001 02:51:34 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!news.tele.dk!193.174.75.178!news-fra1.dfn.de!news-koe1.dfn.de!RRZ.Uni-Koeln.DE!nntp.CS.Uni-Magdeburg.De!PeerFeed.KWeb.on.ca!dnews