Java compilation in terminal gives invalid character errors within string

I'm a beginner and just trying to make the most basic of them all, simple "Hello World"

Here is the code.You will find the same thing anywhere:

class HelloWorld {
    public static void main (String args[]) {
        System.out.println("Hello World!");
    }
}

      

When I launch Terminal (I am using Mac), I get asked with the following errors:

HelloWorld.java:3: error: illegal character: '\u201c'
    System.out.println("Hello World!");
                       ^
HelloWorld.java:3: error: ';' expected
        System.out.println("Hello World!");
                        ^
HelloWorld.java:3: error: not a statement
        System.out.println("Hello World!");
                                  ^
HelloWorld.java:3: error: ';' expected
        System.out.println("Hello World!");
                                       ^
HelloWorld.java:3: error: illegal character: '\u201d'
        System.out.println("Hello World!");
                                        ^
5 errors

      

What's going on here? All errors are string!

+3


source to share


3 answers


"

is the wrong character to use to denote a string - you should use "

.



+5


source


""

invalid String, use ""

. In your code, change from

 System.out.println("Hello World!");

      



For

System.out.println("Hello World!");

      

+3


source


is "different from" in Java.

You need to replace "Hello World!" with "Hello World!"

0


source







All Articles