aspose file tools*
The moose likes Associate Certification (SCJA,OCAJ 5/6) and the fly likes Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Associate Certification (SCJA,OCAJ 5/6)
Bookmark "Error" Watch "Error" New topic
Author

Error

Andrei Mircescu
Greenhorn

Joined: Feb 11, 2009
Posts: 3
i have the next code



and the next errors:
1. class game is public,should be declared in a file named game.java
2. class player is public, should be declared in a file named player.java

i use jcreatorle...

i'm trying to learn java from head first java 2.0, as you may assume, i'm a fast learner.
I'm good at C but i only know to work procedural but now i start to understand OO

please tell me what i'm doing wrong because i can't see the problem...
//best regards
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36514
    
  16
Welcome to JavaRanch

Please use more informative thread titles than "Error."

If you call a class public, then the .java file has to have the same name. You need to write player (It should actually be Player) in a file called player.java, and game (or better Game) in the game.java file. Yes, you need two files. Most compilers enforce that requirement.
Eric Weinberg
Greenhorn

Joined: Nov 11, 2004
Posts: 18
Hello Andrei,

Take some time to read the exceptions and try and get an idea for what they are saying. Java errors usually pretty helpful.

class game is public,should be declared in a file named game.java

It's saying that because the game class is public, the name of the file needs to be called game.java Here is some more information.
Andrei Mircescu
Greenhorn

Joined: Feb 11, 2009
Posts: 3
thank a lot...i've just did my problem...

thank again for the help, i didn't expect to answer me so soon

a question...if i read all the head first java 2 i am ok for scja ?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36514
    
  16
Andrei Mircescu wrote:thank a lot...i've just did my problem...

thank again for the help, i didn't expect to answer me so soon
You're welcome

Andrei Mircescu wrote:a question...if i read all the head first java 2 i am ok for scja ?
Don't know. I shall try moving this thread elsewhere, and see whether you get more answers there.
Andrei Mircescu
Greenhorn

Joined: Feb 11, 2009
Posts: 3
thanks ritchie
Vopli Vidoplyasova
Greenhorn

Joined: Jun 05, 2008
Posts: 26
Andrei Mircescu wrote:a question...if i read all the head first java 2 i am ok for scja ?

No, you're not. Head First Java is awesome, but there's a lot of things you need to know in order to pass the exam not covered in the book. I would recommend both Cameron's books plus practice exam at Sun's website.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error
 
Similar Threads
Major problem with GuessGame code, ch02 of "Head First Java, 2nd edition, covers Java 5.0"
Do I need 1 of 3 seperate .java files???
Head First Java Book, Chapter 2
Please Help with Guessing Game (Head First Java)
Very new to java