简体   繁体   中英

Cannot find symbol in java asking to create a class

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.

您需要在可执行块(方法,静态初始化程序,构造函数等)中编写语句

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM