Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: locals es loco? Date: Thu, 04 Oct 2012 11:45:04 -0400 Organization: A noiseless patient Spider Lines: 17 Message-ID: References: <4b5511c5-799d-4469-9502-cdc39491234b@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 4 Oct 2012 15:45:08 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="ffb8f7085759b339c1002252b48331a4"; logging-data="11265"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/HuGK6+evFamOEIJOIc/NF" User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:15.0) Gecko/20120907 Thunderbird/15.0.1 In-Reply-To: <4b5511c5-799d-4469-9502-cdc39491234b@googlegroups.com> Cancel-Lock: sha1:AwqID8ZOugFWFo1uxyyxp0Zd9lU= Xref: csiph.com comp.lang.java.programmer:19099 On 10/4/2012 10:50 AM, bob smith wrote: > I'm trying to come up with a mnemonic that helps me remember which variables get auto-initialized in Java. Is it just locals that you have to explicitly initialize? Fields (both instance fields and static fields) are always initialized to zero/false/null as appropriate. Parameters of methods and constructors are always initialized by the caller's argument expressions. The variable in a `catch' clause is initialized to refer to whatever was thrown. Nothing else is initialized until and unless you initialize it. -- Eric Sosman esosman@ieee-dot-org.invalid