Article View: borland.public.jbuilder.java.language
Article #19249Re: non-static variable cannot be referenced from a static context
From: James D. Frentress
Date: Thu, 19 Feb 1998 00:00
Date: Thu, 19 Feb 1998 00:00
17 lines
1246 bytes
1246 bytes
Ben Sudbury wrote:
> Can someone explain what this means and how to avoid it?
Just what it says :) You might want to read some Java or OO docs to
understand completely but basically you're accessing an instantiated
variable from a static context. The instantiated variable only has
meaning in an instance of the class (object) whereas a static method or
variable has meaning at the class level. When you say
System.out.println("hello world"), what is System? It's a class but you
haven't instantiated it with System s = new System() right? Well, it's
static (and cannot be instantiated) with class fields and methods.
Hope this helps a bit,
Jim
Technical Details
Message-ID:
<34EC9B3C.CC925823@ForAWhile.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<6cgge4$29424@forums.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,511302bcb3fe29ca X-Google-Attributes: gidf74b3,public From: "James D. Frentress" <Broken@ForAWhile.com> Subject: Re: non-static variable cannot be referenced from a static context Date: 1998/02/19 Message-ID: <34EC9B3C.CC925823@ForAWhile.com> X-Deja-AN: 326703521 Content-Transfer-Encoding: 7bit References: <6cgge4$29424@forums.borland.com> X-Priority: 3 (Normal) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Organization: Microsoft Newsgroups: borland.public.jbuilder.java.language