• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

still this code gives compile time error

 
vijayreddy patil
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
 
Rob Spoor
Sheriff
Pie
Posts: 20512
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Compiles perfectly on my machine (JDK 1.6.0_03)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic