Just started reading 'Beginning Programming in Java for Dummies' and when I got to the first example below, I'm getting errors when i try to compile?

I have the JDK 5 update 9 and the Jcreator IDE installed.
Thanks in advance.

class MyFirstJavaClass {
/**
* Method main
**
* @param args
*
*/
public static void main(String[] args) {
System.out.println(“Chocolate, royalties, sleep”);
}
}

Just started reading 'Beginning Programming in Java for Dummies' and when I got to the first example below, I'm getting errors when i try to compile?

I have the JDK 5 update 9 and the Jcreator IDE installed.
Thanks in advance.

class MyFirstJavaClass {
/**
* Method main
**
* @param args
*
*/
public static void main(String[] args) {
System.out.println(“Chocolate, royalties, sleep”);
}
}

Is it the quotation marks that are causing the problem>

"

Thanks.

No, here are the errors when I took out the quotes.


--------------------Configuration: MyFirstProject - JDK version 1.5.0_09 <Default> - <Default>--------------------
C:\Program Files\Xinox Software\JCreatorV3LE\MyProjects\MyFirstProject\MyFirstClass.java:10: cannot find symbol
symbol : variable Chocolate
location: class MyFirstJavaClass
System.out.println(Chocolate, royalties, sleep);
^
C:\Program Files\Xinox Software\JCreatorV3LE\MyProjects\MyFirstProject\MyFirstClass.java:10: cannot find symbol
symbol : variable royalties
location: class MyFirstJavaClass
System.out.println(Chocolate, royalties, sleep);
^
C:\Program Files\Xinox Software\JCreatorV3LE\MyProjects\MyFirstProject\MyFirstClass.java:10: cannot find symbol
symbol : variable sleep
location: class MyFirstJavaClass
System.out.println(Chocolate, royalties, sleep);
^
3 errors

Process completed.

Nope silly. Observe.

class MyFirstJavaClass {
/**
* Method main
**
* @param args
*
*/
public static void main(String[] args) 
{
  System.out.println("Chocolate, royalties, sleep");
}
}

Try that and I bet you it will work. The question is are you smart enough to realise why.

This article has been dead for over six months. Start a new discussion instead.