Jules
Jules

Reputation: 14520

Getting println error in Eclipse

I'm beginning programming with Java, and it seems Eclipse is giving me errors from day one. Here's my hello, world program:

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

Whenever I try to run the code, though, println gets a red underline, and the line is marked with a red "x" symbol. Eclipse tells me that "println cannot be resolved".

This syntax lines up perfectly with various Hello World programs around the web, as well as the one in the book I'm learning Java from. What am I doing wrong?

Upvotes: 2

Views: 1945

Answers (2)

mickeyreiss
mickeyreiss

Reputation: 490

"Hello World" seems to be surrounded by curly quotes instead of straight quotes in your code.

The reason you're seeing a compilation error is that Java determines which method to use based on both the name of the method and the types of the arguments. println, for instance, takes a String (or a bool, int or other types documented here: http://docs.oracle.com/javase/7/docs/api/java/io/PrintStream.html#println() ).

Your code seems to pass in an unknown type, so println(curly string) cannot be resolved.

Upvotes: 5

Mordechai
Mordechai

Reputation: 16254

The quotes surrounding Hello, World! are not the right type.

Upvotes: 3

Related Questions