aspose file tools
The moose likes Beginning Java and the fly likes still this code gives compile time error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "still this code gives compile time error" Watch "still this code gives compile time error" New topic
Author

still this code gives compile time error

vijayreddy patil
Greenhorn

Joined: Feb 12, 2008
Posts: 5
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)
{
if (guess == cell)
{
result = "hit";
numOfHits++;
break;
}

}

if(numOfHits == locationCells.length)
{
result = "kill";
}
System.out.println(result);
return result;
}
}
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

What error?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19905
    
  23

Compiles perfectly on my machine (JDK 1.6.0_03)


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
wood burning stoves
 
subject: still this code gives compile time error