This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes The Guessing Game Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "The Guessing Game" Watch "The Guessing Game" New topic
Author

The Guessing Game

Spandan Pandey
Greenhorn

Joined: Feb 20, 2013
Posts: 10
I am having a problem in the page 39 guessing game in Headfirst Java.
The command prompt is
GameLauncher.java:1: class GuessGame is public, should be declared in a file nam
ed GuessGame.java
public class GuessGame {
^
GameLauncher.java:65: class Player is public, should be declared in a file named
Player.java
public class Player {
^

So, I separately made .java file containing GuessGame class and Player classs and compiled it.
But still the GameLauncher.java isn't able to compile showing the same error.I don't understand the reason.Now I have separate class files for each of them,it must compile now.
Help!!
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2833
    
  11

Welcome to JavaRanch!

If the compiler still complains that there is a public class Player defined within GameLauncher.java , then there probably is. When you created Player.java, did you also remove the Player class from GameLauncher.java? Did you save your changes after removing it?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: The Guessing Game
 
Similar Threads
Question about classes and running source code.
Guessing Game problem page39 Head First Java
Please Help with Guessing Game (Head First Java)
GuessGame.java:2: cannot resolve symbol
Very new to java