• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

.equal problem question

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi. I'm doing SimpleDotComGeme class for the Had First java book ch.5. heres the error message i get when compiling
:SimpleDotComGame.java: 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};

theDotCom.setLocationCells(locations);

boolean isAlive = true;


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

numOfGuesses++;
if (result.equal("kill")) {
isAlive = false;
System.out.println("You took " + numOfGuesses + "guesses");
} //close if
} //close while
}// close main
} //close class
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It should be named "equals", with an "s"
 
Scott Pike
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you
 
Squanch that. And squanch this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic