jQuery in Action, 3rd edition
The moose likes Beginning Java and the fly likes HeadFirst SimpleDotCom compile Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "HeadFirst SimpleDotCom compile" Watch "HeadFirst SimpleDotCom compile" New topic

HeadFirst SimpleDotCom compile

Harold Kanda

Joined: Apr 04, 2008
Posts: 1
Hello, When compiling the following code I get the following errors:

SimpleDotCom.java:13; ';' expected
for (int cell : locationCells) {
SimpleDotCom.java:25: illegal start of expression
return result;
SimpleDotCom.java:26: illegal start of expression
} // Close Method

public class SimpleDot {

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) {
if (guess == cell) {
result = "hit";
} // End loop

if (numOfHits == locationCells.length) {
result = "kill";
return result;
} // Close Method
} // Close Class

Any help would be appreciated. Thank you.
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

You need to compile this code with at least Java5. Check that you are not using an old version (javac -version)

[My Blog]
All roads lead to JavaRanch
I agree. Here's the link: http://aspose.com/file-tools
subject: HeadFirst SimpleDotCom compile
It's not a secret anymore!