Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiling Java in terminal gives illegal character errors within a string [closed]

Tags:

java

string

I am new and just trying to do the most basic of all, simple 'Hello World'

Here is the code, The same you find anywhere:

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

When I run in the terminal (I use a Mac) I am posed 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 is going on here? All the errors are the string!

like image 375
David Griffith Avatar asked Feb 18 '26 17:02

David Griffith


1 Answers

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

like image 180
Mureinik Avatar answered Feb 20 '26 08:02

Mureinik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!