Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

variable not know in current context

 
Steven Zoraster
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Why am I getting "variable not known in current context" for x in the following code:

float x = 0.0f;
for(int i=0;i<dataIn.length;i++){
x = (float)dataIn[0][i];
float y = (float)dataIn[1][i];
float z = (float)dataIn[2][i];
boolean b = distanceTransform(M,
Gf,dzdx,dzdy,grad,x,y,z);
}

Netbeans documentation says to initialize a variable before using it should cure this problem
 
Stevens Miller
Bartender
Posts: 1223
23
C++ Java Netbeans IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Steven Zoraster wrote:Why am I getting "variable not known in current context" for x in the following code:


Gonna need a little more of that context to be of any help. Can you post the class and method definitions that include this fragment (assuming they're not too long, of course)?

Netbeans documentation says to initialize a variable before using it should cure this problem

If anything, I'd expect that to generate a "The assigned value is never used" warning, rather than solve anything.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic