| Author |
HF Java 2ed
|
marc valente
Greenhorn
Joined: May 24, 2007
Posts: 1
|
|
Hello I am new to java. I am reading HF java and trying to compile code form chapter 2 but i am runing into truble. I am trying to run the Guessing Game code but i get errors saying that the public class for the 3 difernt classes i.e player, GameLunch and GuesGame should be in diferent files and not on the same file. Not sure what to do. thanks, marc
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32675
|
|
Welcome to the Ranch. This is a rule most compilers impose; if you have three public classes called Player, GameLunch and GuessGame, you need three source files with the same names and ".java" extension, ie Player.java, GameLunch.java and GuessGame.java. And convention has it that you write Player rather than player.
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14672
|
|
Well, I'd say that the rule is : one public class per file. So make your class in separate files. If you insist in using only one file, change two of them so that their are not public.
|
[My Blog]
All roads lead to JavaRanch
|
 |
 |
|
|
subject: HF Java 2ed
|
|
|