| Author |
Cannot resolve symbol
|
Maria Garcia
Ranch Hand
Joined: Jul 14, 2002
Posts: 86
|
|
Why is it giving the following error ? GCTest.java:7 <identifier> expected obj = null; GCTest.java:8 <identifier> expected obj2 = null; GCTest.java:7 cannot resolve symbol symbol: class obj location: class GCTest obj = null; GCTest.java:8 cannot resolve symbol symbol: class obj location: class GCTest obj2 = null;
|
SCJP 1.4
|
 |
Tom Adams
Ranch Hand
Joined: Feb 07, 2003
Posts: 56
|
|
I will take a run at this...caveats apply: the obj & obj2 assignment statements need to be place inside a method (maybe the constructor) or inside an instance initilaization block... { obj = null; obj2 = null; }
|
Tom
|
 |
Maria Garcia
Ranch Hand
Joined: Jul 14, 2002
Posts: 86
|
|
I'm still a bit confused...
|
 |
Dan Culache
Ranch Hand
Joined: Jan 24, 2003
Posts: 70
|
|
From the Java specification:
A class body may contain declarations of members of the class, that is, fields (�8.3), classes (�8.5), interfaces (�8.5) and methods (�8.4). A class body may also contain instance initializers (�8.6), static initializers (�8.7), and declarations of constructors (�8.8) for the class.
but obj = null; obj2 = null; are not declarations of a field, class, etc. They are assignments. They should be placed within one of the entities in the mentioned list. Helpful?
|
 |
Maria Garcia
Ranch Hand
Joined: Jul 14, 2002
Posts: 86
|
|
|
Hmmm... thanks! Everything's clear now
|
 |
 |
|
|
subject: Cannot resolve symbol
|
|
|