Jump to content
  • Advertisement
Sign in to follow this  
PythonRulez

[java] Why won't my code work?

This topic is 4158 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I can't tell if this is a problem with my code, or with my compiler/IDE. I am using JCreator, and I am trying to make my code print my name, address and telephone number (book exercise) however, I get an error saying "'{' expected on line 10" and "'}' expected on line 22" but I have them on those lines I think what am I doing wrong? Also, if it is my IDE, what should I do to change it? Or should I switch IDE, and if so, what to? Here is my code:
/**
 * @(#)Exercise 2.java
 *
 * Exercise 2 application
 *
 * Sophie Marston 
 * version 1.00 2007/2/1
 */
 
public class Exercise 2 {
    
    public static void main(String[] args) {
    	
    	// Print my name 
    	System.out.println("Sophie Marston");
    	// Print my address
    	System.out.println("Somewhere");
    	// Pritn my telephone number
    	System.out.println("NEVER!");
    }
}
[Edited by - PythonRulez on February 1, 2007 2:07:31 PM]

Share this post


Link to post
Share on other sites
Advertisement
You have a blank in your class name: public class Exercise_2 {
Simply remove the blank in the class name.

Share this post


Link to post
Share on other sites
It is not homework. I am trying to learn Java from the book Java in 2 Semesters, I have used other languages, but not Java. I am only 14, my school doesn't do programming classes except for A level.

Share this post


Link to post
Share on other sites
Also, your life as a programmer will be much more pleasant if you accept the following truth right now: If your code won't compile, it's your fault.

Share this post


Link to post
Share on other sites
The code didn't compile because and it was my fault because I was being extremely stupid and not checking my code myself and only looking at the compiler error messages.

Share this post


Link to post
Share on other sites
Well, today, you have learned a very important lesson about compilers: when a compiler says "Was expecting X", it doesn't mean that X wasn't present, but that Y was encountered before X was, but wasn't expected.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!