Reputation:
I am having a class defined as follows:
public class Myclass {
public int myvariable = 100;
if( myvariable > 0) {
}
}
Why I am getting an error in front of if condition
stating that cannot find symbol , symbol : class myvariable , location : class Myclass <identifier> expected
I am just comparing the value of integer variable with 0 here. Based on the error, I would need to create a class. Please let me know what's wrong here.
Upvotes: 1
Views: 128
Reputation: 240918
You need to write statement inside executable block (method, static initializer, constructor etc)
Upvotes: 2