File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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 Android Security Essentials Live Lessons this week in the Android 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: 19655
    
  18

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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: still this code gives compile time error
 
Similar Threads
Beginner Ques. from Head Start Java book
HeadFirst SimpleDotCom compile
Enhanced for loop
i am still getting compile time error in this program plz give me solution
Getting 6 errors with the use of result(noob)