i'm receiving this error with my java application. I believe the fault is with the add function for my array list. Is there a better way of incorporating this idea without going too complex? (First week of java) Thanks a lot guys!
import java.util.ArrayList;
import java.util.Scanner;
public class PrimeSieve {
public static void main(int[] args) {
System.out.println("Enter the max integer(N value): ");
Scanner scan = new Scanner(System.in);
int num = scan.nextInt();
System.out.println("Compute prime numbers from 2 to: " + num);
if(num < 2){
System.out.println("N must be greater than or equal to 2.");
}
else if(num == 2) {
System.out.println("Prime numbers: 2");
}
else {
ArrayList<Integer> myArr = new ArrayList<Integer>();
int i = 2;
while(i <= num){
myArr.add(i);
}
System.out.println(myArr);
}
}
}
The error -
Exception in thread "main" java.lang.NoSuchMethodError: main