Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #34148

Re: Another question on Java keyword "this".

From Eric Sosman <esosman@comcast-dot-net.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: Another question on Java keyword "this".
Date 2016-04-15 18:26 -0400
Organization A noiseless patient Spider
Message-ID <nerpka$c7n$1@dont-email.me> (permalink)
References <7d6a2a1e-bf53-472c-8ec2-2c92a0b5f73e@googlegroups.com> <8bd83f19-b47f-43e8-9acb-d3d4ed125a2a@googlegroups.com>

Show all headers | View raw


On 4/15/2016 5:45 PM, cdalten@gmail.com wrote:
> On Thursday, April 14, 2016 at 11:27:34 PM UTC-7, cda...@gmail.com wrote:
>> In the follow code found at...
>>
>> https://github.com/googlemaps/android-samples/blob/master/ApiDemos/app/src/main/java/com/example/mapdemo/GroundOverlayDemoActivity.java
>>
>> What does "this" in
>>
>> map.setOnGroundOverlayClickListener(this);
>>
>> refer to?
>
> I thought about it. I think I found out what's irking me. Does
>
> map.setOnGroundOverlayClickListener(this);
>
> Implement something? If so, what does it implement?

     The identifier `map' refers to some kind of object.  (It may refer
to it by the object's actual class name, or by the name of a superclass,
or by the name of an interface implemented by the object's class -- but
in any event, `map' refers to some kind of an object.)

     The referred-to object is an instance of a class that has (or maybe
inherits) a method named `setOnGroundOverlayClickListener'.  That
method has one parameter (or possibly more, but that would just
confuse you to the point where your head might explode), and that
parameter is declared with some particular type: Again, a class or
perhaps an interface.

     Assuming that the code compiles, the object referred to by `this'
belongs to a class that is compatible with the method's parameter.
By "compatible with," I mean that the `this' object is either of the
class declared for the parameter, or is a subclass of that class, or
(if the parameter is declared with an interface type) is a class that
implements that interface or one of its sub-interfaces.

     ... and all of this is *elementary*, the kind of stuff that's
covered in "Java 101," probably by the fifth or sixth class meeting
and certainly before the tenth.  I really think you should heed Lew's
advice about doing some introductory reading before diving in with
questions at the level of "What's an `int'?"  Usenet is a fine medium
for handling directed inquiries, but a poor one for the mass transfer
of basic information.  It's like taking a correspondence course over
Twitter.  Seek other approaches.

-- 
esosman@comcast-dot-net.invalid
"Don't be afraid of work. Make work afraid of you." -- TLM

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Another question on Java keyword "this". cdalten@gmail.com - 2016-04-14 23:27 -0700
  Re: Another question on Java keyword "this". Eric Douglas <e.d.programmer@gmail.com> - 2016-04-15 04:59 -0700
    Re: Another question on Java keyword "this". cdalten@gmail.com - 2016-04-15 05:14 -0700
      Re: Another question on Java keyword "this". cdalten@gmail.com - 2016-04-15 05:31 -0700
        Re: Another question on Java keyword "this". Nigel Wade <nmw@ion.le.ac.uk> - 2016-04-15 14:05 +0100
          Re: Another question on Java keyword "this". Eric Douglas <e.d.programmer@gmail.com> - 2016-04-15 06:25 -0700
        Re: Another question on Java keyword "this". Lew <lewbloch@gmail.com> - 2016-04-15 14:48 -0700
      Re: Another question on Java keyword "this". Brixomatic <brixomatic@yahoo.com> - 2016-04-23 15:01 +0200
      Re: Another question on Java keyword "this". Roedy Green <inquiry@mindprod.com> - 2016-06-04 03:15 -0700
        Re: Another question on Java keyword "this". Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> - 2016-06-04 14:34 +0300
          Re: Another question on Java keyword "this". Mike Amling <mamling@chaff.us> - 2016-06-04 14:07 -0500
    Re: Another question on Java keyword "this". Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-04-15 08:24 -0400
  Re: Another question on Java keyword "this". cdalten@gmail.com - 2016-04-15 14:45 -0700
    Re: Another question on Java keyword "this". Lew <lewbloch@gmail.com> - 2016-04-15 14:52 -0700
    Re: Another question on Java keyword "this". Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-04-15 18:26 -0400
      Re: Another question on Java keyword "this". cdalten@gmail.com - 2016-04-17 19:13 -0700
        Re: Another question on Java keyword "this". Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-04-18 07:37 -0400

csiph-web