I am useing the book "Head First Java" 2nd edition trying to teach myself
Java programing
Right now I am just trying to construct a game called SimpleDotCom. I don't know if it is somthing I have missed in the reading but every time I try to compile this code I get three errors I don't under stand My code is identical to the code from the book. Is there any way to help me out and get me back on the right track?
public class SimpleDotCom {
int[] locationCells;
int numOfHits = 0;
public void setLocationCells (int[] locs) {
locationCells = locs;
}
public
String checkYourself(String stringGuess) {
int guess = Integer.parseInt(stringGuess);
String result ="miss";
for (int cell : locationCells) { ""the first error is here the compiler is telling me the : is wrong""
if (guess == cell) {
result = "hit";
numOfHits++;
break;
}
} // out of loop
if (numOfHits == locationCells.length) {
result ="kill";
}
System.out.println(result);
return result; ""Second error is here illegal start of expression""
} // close method ""Last one in here illegal start of expression""
} // close class
What did I do wrong that it won't compile?