Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #8133
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsfeed.utanet.at!newsfeed01.chello.at!newscore.univie.ac.at!aconews-feed.univie.ac.at!aconews.univie.ac.at!not-for-mail |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| From | Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> |
| Subject | Re: super |
| References | <3e87dcf3-6842-41bf-8eb8-0c4181a178a9@k1g2000vbz.googlegroups.com> <j55ad2$o2g$1@dont-email.me> |
| Reply-To | avl@logic.at |
| User-Agent | slrn/pre0.9.9-111 (Linux) |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Content-Transfer-Encoding | 7bit |
| Message-ID | <slrnj7cdtu.6gl.avl@gamma.logic.tuwien.ac.at> (permalink) |
| Date | 18 Sep 2011 18:26:06 GMT |
| Lines | 23 |
| NNTP-Posting-Host | gamma.logic.tuwien.ac.at |
| X-Trace | 1316370366 tunews.univie.ac.at 11354 128.130.175.3 |
| X-Complaints-To | abuse@tuwien.ac.at |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:8133 |
Show key headers only | View raw
Joshua Cranmer <Pidgeot18@verizon.invalid> wrote: > On 9/18/2011 11:53 AM, giuseppe.on.usenet wrote: >> When I run dir2.Child, I get: >> var is 1 >> which is what I was expecting. >> When I run dir2.GrandChild, I get: >> super.var is 2 >> var is 2 >> These last two variables have the same value, although I only modified >> gc.var in GrandChild.java. Why? > How many times did you declare a variable named `var'? By my count, you > defined it once, so `var' and `super.var' both refer to the same > variable `var', namely the one defined in Parent. I think the misunderstanding is far more basic. To giuseppe: In dir2.GrandChild's main, just remove the line, where you instantiate Child, and leave the rest exactly as is. Recompile & run it. You'll see that instantiating class Child (or not doing it) doesn't change anything. What does this tell you?
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
super "giuseppe.on.usenet" <giuseppe.on.usenet@gmail.com> - 2011-09-18 09:53 -0700
Re: super Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-09-18 12:39 -0500
Re: super Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-09-18 18:26 +0000
Re: super Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-09-18 18:29 +0000
Re: super "giuseppe.on.usenet" <giuseppe.on.usenet@gmail.com> - 2011-09-18 12:21 -0700
Re: super Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-09-18 19:48 +0000
Re: super Lew <lewbloch@gmail.com> - 2011-09-18 13:16 -0700
csiph-web