Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: markspace <-@.> Newsgroups: comp.lang.java.programmer Subject: Re: borrowing Constants Date: Fri, 23 Sep 2011 18:44:57 -0700 Organization: A noiseless patient Spider Lines: 17 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 24 Sep 2011 01:45:02 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="XjIWM99mD7Ijfdu600oVPA"; logging-data="18266"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/fsVY444m63rr6VH7wfpUzktUzrdy0aKA=" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.2) Gecko/20110902 Thunderbird/6.0.2 In-Reply-To: Cancel-Lock: sha1:ztMzePle3Rwj7tePQNXvA+mord0= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:8252 On 9/23/2011 5:40 PM, Roedy Green wrote: > When you use Class B, does all of class A get instantiated? > Does all of class A get put in B's jar? I think so, yes. Not "instantiated" as others pointed out but initialized. But yes, regardless. I believe you can get around this by making VERSION final. The compiler is allowed (possibly required?) to copy final static values as a kind of constant, in order to avoid this kind of unneeded initialization. class A { static final String VERSION = "1.0b"; }