Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Cannot resolve symbol

 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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;
 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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;
}
 
Maria Garcia
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm still a bit confused...
 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmmm... thanks! Everything's clear now
 
There is no beard big enough to make me comfortable enough with my masculinity to wear pink. Tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic