🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Language puzzle

#7944
From: John McGrath [TeamB]
Date: Thu, 03 May 2001 00:22
29 lines
2151 bytes
"Harry Whitehouse" <harry@envmgr.com> wrote:

> Is it possible that boolean b would ever be undefined?
> IOW,  neither set to true or false?

No, that is not possible.  Because of the definite assignment rules (see my
previous message to Valentino), uninitialized variables cannot possibly be
referenced in a Java program.  If the method were called specifying an
argument that might not be initialized, it would result in a compiler error
at the method call.

> I did a quick test in JB4 and simply declaring 'boolean b'
> seems to set it to false (at least in the debug mode)

You must have declared a member variable.  These are always given a default
value, even before the class's constructor is called.  Numeric, character,
and byte types are initialized to zero, booleans to false, and reference
types to null.

Stack variables (declared within the body of a method) are not initialized
this way.  If you declared a stack variable without initializing it, and
then tried to use the variable (for example, print it), you would have
gotten a compiler error saying that the value might not be defined.  Again,
this is due to the "definite assignment" rules.

--
Regards,

John McGrath  [TeamB]
Technical Details
Message-ID: <3af0a4de$2_1@dnews>
Path: arc1-ca.pugleaf.net!newsfeed.google.com!sn-xit-03!supernews.com!cyclone-sjo1.usenetserver.com!news-out-sjo.usenetserver.com!europa.netcrusader.net!128.230.129.106!news.maxwell.syr.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews
References: <3aef3645_1@dnews> <3af06e6d$1_1@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,b65cd5c59c7b0e70
X-Google-Attributes: gidf74b3,public
X-Google-ArrivalTime: 2001-05-02 17:28:03 PST
From: "John McGrath  [TeamB]" <ng-b@JPMcGrath.net>
Newsgroups: borland.public.jbuilder.java.language
References: <3aef3645_1@dnews> <3af06e6d$1_1@dnews>
Subject: Re: Language puzzle
Date: Wed, 2 May 2001 20:22:54 -0400
Lines: 31
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2919.6600
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600
NNTP-Posting-Host: 204.120.92.34
Message-ID: <3af0a4de$2_1@dnews>
X-Trace: dnews 988849374 204.120.92.34 (2 May 2001 17:22:54 -0700)
Path: arc1-ca.pugleaf.net!newsfeed.google.com!sn-xit-03!supernews.com!cyclone-sjo1.usenetserver.com!news-out-sjo.usenetserver.com!europa.netcrusader.net!128.230.129.106!news.maxwell.syr.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews