答案 0 :(得分:0)
您不能将System.out.println()
用于任何类属性。
声明使用println()
打印任何内容的任何方法和内部。
请看以下示例:
public class Test {
static String string;
//the following println() will create the error: Multiple markers at this line
//- Syntax error on token(s) bla bla bla
System.out.println("hello");
public void printSomething() {
//But this is ok
System.out.println("hello");
}
public static void main(String[] args) {
Test test = new Test();
test.printSomething(); // prints hello
}
}