static 方法里只能访问 static变量 a不是static
正确代码如下public class Animal {
static int a = 90;
static float b = 10.98f;
public static void main(String args[]){
float c = a+b;
System.out.println("c = " + c);
}
}
正确代码如下public class Animal {
static int a = 90;
static float b = 10.98f;
public static void main(String args[]){
float c = a+b;
System.out.println("c = " + c);
}
}
public class Animal {
static 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 float b = 10.98f;
public static void main(String args[]){
Animal animal = new Animal();
float c = animal.a+b;
System.out.println("c = " + c);
}
}