🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Q: Static variables are initialized twice

#18825
From: Conrad Hoesle-Kienzlen
Date: Tue, 21 Apr 1998 00:00
62 lines
2064 bytes
Eiji,
are you talking of an applet or an application? Because it is not uncommon fo
an applet to have it's init() method called twice. MS Internet Exploder always
calls init() after the page with the applet has been left and recalled, or
after the browser window has been minimized and maximized again.
...Conrad

Eiji Nabika wrote:

> I have trouble with static variables.
>
> Some static variables seem to be initialized several times. So, I lost
> values stored before.
>
> The example is as follows:
>
> class Foo {
>    public static String foo = "init";     // --------(1)
> }
>
> class SomeClass {
>    public void setFoo() {
>        Foo.foo = "SomeClass";
>    }
> }
>
> class AnohterClass {
>    public String getFoo() {
>        return (Foo.foo);
>    }
> }
>
> If I invoke getFoo() method after invoking setFoo() , the result should
> be "SomeClass", but
> sometimes it returns "init".  I found the initialization process (1)
> executed twice,
> but I don't know how to avoid it. Could anyone tell me?
>
> ---
> Eiji Nabika
>
>   ------------------------------------------------------------------------
>
>   Eiji Nabika <nabika@cs.uiuc.edu>
>
>   Eiji Nabika
>     <nabika@cs.uiuc.edu>
>     Netscape Conference Address
>     Netscape Conference DLS Server
>   Additional Information:
>   Last Name
>   First Name Eiji Nabika
>   Version    2.1



--
Conrad Hoesle-Kienzlen
CHK IT-Consulting

<http://ourworld.compuserve.com/homepages/conrad_hoesle>
Technical Details
Message-ID: <353CE4AE.3E5E8EBD@csi.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <353CBAA3.FE39CEC6@cs.uiuc.edu>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,ce6ec45ee05bcd5c
X-Google-Attributes: gidf74b3,public
From: Conrad Hoesle-Kienzlen <Conrad_Hoesle@csi.com>
Subject: Re: Q: Static variables are  initialized twice
Date: 1998/04/21
Message-ID: <353CE4AE.3E5E8EBD@csi.com>
X-Deja-AN: 346379434
Content-Transfer-Encoding: 7bit
References: <353CBAA3.FE39CEC6@cs.uiuc.edu>
Content-Type: text/plain; charset=us-ascii
Organization: CHK IT-Consulting
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language