Reputation: 1
So this is what I am dealing with:
System.out.println("Hey dude, welcome to " The World ".");
And i get:
prog.java:3: error: ';' expected
Other than adding the \
escape to fix it I don't know what this error means?
can someone explain?
Upvotes: 0
Views: 75
Reputation: 254
To actually explain... Your error means that the system (compiler) did expect the line to end after
"Hey dude, welcome to "
or rather, did not expect the line to continue with
The World
Because The World is neither a variable nor method name it can use, you get this synthax error. What it did expect to get was something like the others have posted before. Another example using yours...
String welcomeTo = "The World";
System.out.println("Hey dude, welcome to " + welcomeTo + ".");
Keep going, we all started there.
Upvotes: 1
Reputation: 41
You must use escape character '\"'
for use " in String.
Example:
System.out.println("Hello \"World\"");
Print: Hello "World"
Upvotes: 3