static int basketballPlayer;
static int activebasketballPlayers;
static int legendbasketballPlayers;
非法开始表达
在 Java 中,static
修饰符适用于类、字段和方法。请参阅了解类成员,其中简要讨论了修饰符的使用。
class Foo {
static int foo; // okay - static applied to field
}
但是static
不能与 Java 中的局部变量一起使用
class Bar {
void x () {
static int bar; // fail - static cannot be applied to local variables
}
}
上面的结果是熟悉的编译器错误:
error: illegal start of expression
static int bar;
只有在类开始时声明字段时,才能使用 static
。如果尝试在方法中声明这些,则不能使用 static。
我可以向你推荐这个,它应该可以帮助你理解Java:http://docs.oracle.com/javase/tutorial/java/javaOO/variables.html