Skip to main content
gamedev.net
🔒 Locked

[java] Why won't my code work?

Started by PythonRulez 5 replies 1.1k views
Original Post
PythonRulez
PythonRulez
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]
Alrecenk
Alrecenk
You can't have a space in your class name, and this forum doesn't like homework posts.
baumep
baumep
You have a blank in your class name: public class Exercise_2 {
Simply remove the blank in the class name.
baumep
PythonRulez
PythonRulez
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.
Simian Man
Simian Man
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.
PythonRulez
PythonRulez
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.
ToohrVyk
ToohrVyk
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.