import java.util.Scanner;
public class primenumbertest {
public boolean isPrime(int num){
int x;
Scanner input = new Scanner(System.in);
System.out.print("Enter a number to find out if it's prime or not (greater than 1): ");
num = input.nextInt();
if (num == 2) return true;
// check for divisible by all even number
if (num % 2 == 0) return false;
// check for odd number only
for (int i = 3; i < num; i=i+2){
if (num % i == 0) return false;
}
return true; // all test pass..number is prime
}
}
Beginner to Java. Getting the error, java.lang.NoSuchMethodError: main... Exception in thread "main"
A way to fix this?
Thanks!