我有一个Java错误,其中包含多种说法
')'预计不会发表声明
和
&#39 ;;'预计不会发表声明
错误消息的重点是我的代码的System.out.println行:
package a1main;
public class A1main
{
public static void main(String[] args)
{
String Name = "J'on J'onzz.";
String Address = "123 Avenue Drive,";
String City = "Oogie's Lair,";
String State = "Halloweentown,";
String ZCode = "12345.";
String PNumber = "(630) 867-5309.";
String CMajor = "Coding, Drugs, and Rock and Roll.";
System.out.println("My name is" + Name "My address is" + Address "which is located in" + City + State + ZCode "My phone number is" + PNumber "My college major is" + CMajor);
}
}
有人可以帮忙吗?
这里的相关论坛帮助我清理了其他错误,但我仍然坚持这个错误......我只知道这个错误可能会沾沾自喜地盯着我。
答案 0 :(得分:1)
应该是
System.out.println("My name is" + Name + "My address is" + Address + "which is located in" + City + State + ZCode + "My phone number is" + PNumber + "My college major is" + CMajor);
缺少多个+
。
答案 1 :(得分:0)
最后一行需要变量和常量之间的额外加号。
System.out.println("My name is" + Name + "My address is" + Address + "which is located in" + City + State + ZCode + "My phone number is" + PNumber + "My college major is" + CMajor);
答案 2 :(得分:0)
您在变量和字符串之间缺少一些字符串连接运算符:
System.out.println("My name is" + Name + "My address is" + Address + "which is located in" + City + State + ZCode + "My phone number is" + PNumber + "My college major is" + CMajor);
答案 3 :(得分:0)
您忘记在+
之后添加PNumber
。它应该是
System.out.println("My name is" + Name "My address is" + Address "which is located in" + City + State + ZCode "My phone number is" + PNumber + "My college major is" + CMajor);
通过Stack Overflow提出这些问题不是一个好主意。