作业帮 > 综合 > 作业

java中的Cannot make a static reference to the non-static field

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/06/03 13:36:03
java中的Cannot make a static reference to the non-static field a是什么错误?
请问程序有什么错误?
public class Takecare{
int a=90;
static float b=10.98f;
public static void main(String[] args) {
float c=a+b;
System.out.println("c="+c);
}
}
无法在静态方法中引用非静态变量
int a=90;改成 static int a=90;