Issue
I'm new to Java and trying to do a simple count operation in a for loop:
public boolean play(Matrix matrix){
int dimension = matrix.getDimension();
int count=0;
for(int x=0;x<dimension;x++){
for(int y=0;y<dimension;y++){
count++;
}
}
return true;
}
The error I get is related to count and is as in the title: Variable is assigned but never accessed. The variable count should have been initialized outside the for loop and then accessed inside the for loop, I don't understand where the problem is located.
Solution
Like GriffeyDog wrote: You never use (read from) the variable count, you just assign to it. That was the problem.
Answered By - Spyromancer
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.