File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes .equal problem question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark ".equal problem question" Watch ".equal problem question" New topic

.equal problem question

Scott Pike

Joined: Jan 17, 2007
Posts: 12
hi. I'm doing SimpleDotComGeme class for the Had First java book ch.5. heres the error message i get when compiling cannot find symbol
symbol: method equal(java.lang. String)
location: class java.lang.String
if (result.equal("kill")) { theres a little arrow that points at the period point between result word and the equal word , the period. What is wrong?

Heres the rest of the class code if that helps.

public class SimpleDotComGame {
public static void main(String[] args) {

int numOfGuesses = 0;

GameHelper helper = new GameHelper();

SimpleDotCom theDotCom = new SimpleDotCom();

int randomNum = (int) (Math.random() * 5);

int[] locations = {randomNum, randomNum+1, randomNum+2};


boolean isAlive = true;

while(isAlive == true) {
String guess = helper.getUserInput("enter a number");
String result = theDotCom.checkYourself(guess);

if (result.equal("kill")) {
isAlive = false;
System.out.println("You took " + numOfGuesses + "guesses");
} //close if
} //close while
}// close main
} //close class
Christophe Verré

Joined: Nov 24, 2005
Posts: 14687

It should be named "equals", with an "s"

[My Blog]
All roads lead to JavaRanch
Scott Pike

Joined: Jan 17, 2007
Posts: 12
thank you
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: .equal problem question
Similar Threads
Hi All, While working with Head first java, I got into a problem, please help me to solve this.....
Help with code
Help With With HeadFirst Java Chap.6
HeadFirst DotComBust... Help?
HFJ 2nd - Problem with SimpleDotCom