Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #6735

Re: What are the different scopes for Java variables?

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!74.125.46.80.MISMATCH!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
From Lew <lewbloch@gmail.com>
Newsgroups comp.lang.java.programmer
Subject Re: What are the different scopes for Java variables?
Date Tue, 2 Aug 2011 00:01:22 -0700 (PDT)
Organization http://groups.google.com
Lines 30
Message-ID <73d7cd03-cc86-4334-8833-20af4e599427@glegroupsg2000goo.googlegroups.com> (permalink)
References <92093457-2ea3-44c5-a6fc-536842511687@k9g2000yqf.googlegroups.com>
Reply-To comp.lang.java.programmer@googlegroups.com
NNTP-Posting-Host 108.89.33.208
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1
X-Trace posting.google.com 1312268483 11346 127.0.0.1 (2 Aug 2011 07:01:23 GMT)
X-Complaints-To groups-abuse@google.com
NNTP-Posting-Date Tue, 2 Aug 2011 07:01:23 +0000 (UTC)
In-Reply-To <92093457-2ea3-44c5-a6fc-536842511687@k9g2000yqf.googlegroups.com>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=108.89.33.208; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T
User-Agent G2/1.0
X-Google-Web-Client true
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:6735

Show key headers only | View raw


"Software Engineer" wrote:
> What are the different scopes for Java variables?
> 
> The scope of a Java variable is determined by the context in which the
> variable is declared. Thus a java [sic] variable can have one of the three
> scopes at any given point in time.
> 1. Instance : - These are typical object level variables, they are
> initialized to default values at the time of creation of object, and
> remain accessible as long as the object accessible [sic].
> 2. Local : - These are the variables that are defined within a method.
> They remain accessbile only during the course of method excecution.
> When the method finishes execution, these variables fall out of scope.
> 3. Static: - These are the class level variables. They are initialized
> when the class is loaded in JVM for the first time and remain there as

That is not true.  They are not initialized when the class is loaded, but later.

Check your facts.  It's in the JLS (Java Language Specification).

> long as the class remains loaded. They are not tied to any particular
> object instance.

It's a good start, but incomplete and not entirely accurate.  Check your facts and try again.

markspace gave you a link to a (correct) tutorial and mentioned a couple of things you omitted.  

Yay, Brenden.  He's a good programmer.

-- 
Lew

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Find similar


Thread

What are the different scopes for Java variables? Software Engineer <betsy_gate@yahoo.com> - 2011-07-31 19:18 -0700
  Re: What are the different scopes for Java variables? markspace <-@.> - 2011-07-31 20:15 -0700
  Re: What are the different scopes for Java variables? Lew <lewbloch@gmail.com> - 2011-08-02 00:01 -0700

csiph-web