我尝试编写一些简单的代码来连接两个字符串并打印它们:
class A {
public static void main(String[] args) {
String goto = "jon skeet";
System.out.println("the go-to guy for java questions is " + goto);
}
}
但它得到了所有这些错误:
$ javac A.java && java A
A.java:3: not a statement
String goto = "jon skeet";
^
A.java:3: ';' expected
String goto = "jon skeet";
^
A.java:4: illegal start of expression
System.out.println("the go-to guy for java questions is " + goto);
^
A.java:4: ';' expected
System.out.println("the go-to guy for java questions is " + goto);
^
4 errors
为什么?