Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HF Java 2ed

 
marc valente
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 48985
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic