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”);
}
}

Recommended Answers

All 5 Replies

Member Avatar for iamthwee

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.

Member Avatar for iamthwee

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.

I see now, thanks, I copy and pasted that code from a pdf.

Member Avatar for iamthwee

Well done. Pat yourself on the back.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.