🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Q: Static variables are initialized twice

#18823
From: Eiji Nabika
Date: Tue, 21 Apr 1998 00:00
56 lines
1841 bytes
This is a multi-part message in MIME format.
--------------F2BE7026F41360C3D8E23E34
Content-Type: text/plain; charset=iso-2022-jp
Content-Transfer-Encoding: 7bit

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
--------------F2BE7026F41360C3D8E23E34
Content-Type: text/x-vcard; charset=iso-2022-jp; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Eiji Nabika �̶���
Content-Disposition: attachment; filename="vcard.vcf"

begin:          vcard
fn:             Eiji Nabika
n:              ;Eiji Nabika
email;internet: nabika@cs.uiuc.edu
x-mozilla-cpt:  ;0
x-mozilla-html: FALSE
version:        2.1
end:            vcard


--------------F2BE7026F41360C3D8E23E34--
Technical Details
Message-ID: <353CBAA3.FE39CEC6@cs.uiuc.edu>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,ce6ec45ee05bcd5c,start
X-Google-Attributes: gidf74b3,public
From: Eiji Nabika <nabika@cs.uiuc.edu>
Subject: Q: Static variables are  initialized twice
Date: 1998/04/21
Message-ID: <353CBAA3.FE39CEC6@cs.uiuc.edu>
X-Deja-AN: 346323538
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="------------F2BE7026F41360C3D8E23E34"
Organization: UIUC Pattern Group
Newsgroups: borland.public.jbuilder.java.language