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


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

Re: Need help with a program.

From "Lew" <lew@1:261/38.remove-fzq-this>
Subject Re: Need help with a program.
Message-ID <50327C3E.57171.calajapr@time.synchro.net> (permalink)
Newsgroups comp.lang.java.programmer
References <50327C3D.57167.calajapr@time.synchro.net>
Date 2012-08-20 18:58 +0000
Organization tds.net

Show all headers | View raw


  To: yanamandra
From: Lew <noone@lewscanon.com>

On 08/20/2012 03:39 AM, yanamandra wrote:
> On Monday, August 20, 2012 3:46:52 PM UTC+5:30, Leif Roar Moldskred wrote:
>> yanamandra wrote: > > I am talking about inherited variables. there is i1,
i2 and i3 in > the super class with a method printall. there are the same 3 > 
variables in the derived class but there is no printall method in > the sub 
class. No, those are three _different_ variables which happen to have the same 
names as variables in the base class. You have _six_ variables in play here, 
not three. That's what's causing you problems. -- Leif Roar Moldskred
>
> Yes, as per the output, it looks like that. But, where can I confirm that all
three are different variables? Can I print addresses of the 3 variables, or is 
there any utility in java that can print the output similar to "nm"?
>
> Also, for the output I need, 40, 50 and 60, I will have to re-write the
printall() function. Is that the only way?
>

Variables are not overridden, but methods can be.

All six variables in your question are 'static', meaning they belong to the 
class rather than the instance. The variables in the subclass "hide" (not 
"shadow") the declarations from the superclass.

You can make an overrideable instance method that reports the values of the 
(potentially hidden) variables as seen by the override.

The advice upthread to look up "shadowing", albeit the wrong concept, was not 
so far wrong that it wouldn't have led to the right concept, had you not 
summarily rejected it.

--
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg

--- BBBS/Li6 v4.10 Dada-1
 * Origin: Prism bbs (1:261/38)
--- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24

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


Thread

Re: Need help with a program. "Leif Roar Moldskred" <leif.roar.moldskred@1:261/38.remove-fzq-this> - 2012-08-20 18:58 +0000
  Re: Need help with a program. "yanamandra" <yanamandra@1:261/38.remove-fzq-this> - 2012-08-20 18:58 +0000
    Re: Need help with a program. "Leif Roar Moldskred" <leif.roar.moldskred@1:261/38.remove-fzq-this> - 2012-08-20 18:58 +0000
      Re: Need help with a program. "yanamandra" <yanamandra@1:261/38.remove-fzq-this> - 2012-08-20 18:58 +0000
        Re: Need help with a program. "Leif Roar Moldskred" <leif.roar.moldskred@1:261/38.remove-fzq-this> - 2012-08-20 18:58 +0000
          Re: Need help with a program. "yanamandra" <yanamandra@1:261/38.remove-fzq-this> - 2012-08-20 18:58 +0000
        Re: Need help with a program. "Lew" <lew@1:261/38.remove-fzq-this> - 2012-08-20 18:58 +0000

csiph-web