Results 1 to 4 of 4
Thread: Find the Error in Class Code
- 03-30-2011, 04:23 PM #1
Member
- Join Date
- Mar 2011
- Posts
- 88
- Rep Power
- 0
Find the Error in Class Code
Hello. I copying some code for a class from a text on Java. Even though I beleive I have gotten the code correct, I get error messages, Can anyone helps me resolve this?
The code:
The error messages on compiling:Java Code:public class Primefinder implements Runnable { public long target; public long prime; public boolean finished = false; private Thread runner; PrimeFinder(long inTarget) { target = inTarget; if (runner == null) { runner = new Thread(this); runner.start(); } } public void run() { long numPrime = 0; long candidates = 2; while (numPrime < target) { if (isPrime(candidate)) { numPrimes++; prime = candidate; } candidate++; } finished = true; } boolean isPrime(long checkNumber) { double root = Math.sqrt(checkNumber); for (int i =2; i <= root; i++) { if (checkNumber % i == 0) return false; } return true; } }
"invalid method declaration; return type required"
"PrimeFinder(long inTarget) {'
Thank you.
- 03-30-2011, 04:26 PM #2
Java is case sensitive - look at the class name and the constructor name.
The f is in a different case
- 03-30-2011, 04:27 PM #3
Member
- Join Date
- Jan 2011
- Posts
- 9
- Rep Power
- 0
Hi
you are declaring Primefinder class constructor PrimeFinder .F should be in small case i.e. exactly same as class name
- 03-30-2011, 04:43 PM #4
Member
- Join Date
- Mar 2011
- Posts
- 88
- Rep Power
- 0
Similar Threads
-
Error: Could Not Find Main Class. Program Will Exit
By silvia in forum New To JavaReplies: 2Last Post: 09-22-2011, 09:48 PM -
runtime error 'could not find main class' ?
By ruud00000 in forum Java AppletsReplies: 5Last Post: 12-31-2010, 05:58 PM -
[SOLVED] Could not find the main class: error...
By bobleny in forum New To JavaReplies: 21Last Post: 03-02-2010, 10:53 AM -
could not find main class, the program wil exit-- error in jar file
By nishant.4545 in forum Advanced JavaReplies: 1Last Post: 07-03-2009, 08:41 PM -
cannot find symbol class error
By po0oker in forum New To JavaReplies: 5Last Post: 10-31-2007, 02:52 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks