aspose file tools*
The moose likes Beginning Java and the fly likes HF Java 2ed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "HF Java 2ed" Watch "HF Java 2ed" New topic
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: 36579
    
  16
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: 14687
    
  16

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HF Java 2ed
 
Similar Threads
WTF on page 371
guidelines needed for the exam
HF Design pattern book - What pattern is not cover
anyone use "Java Servlet and JSP cookbook" from O'reilly?
HF Servlets & JSP available in local store (Michigan)