0

I assume I am making a dumb error somewhere, but when I run the following code on both Codecademy's IDE and Replit I get hit with this error:

Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main

Is there something obviously wrong with how I structured my Java class? I have reviewed this answer but it's still not clear to me why I am hitting this error.

import java.util.ArrayList;

// Goal: find which elements of a list in main are prime 

class PrimeDirective {

  private static ArrayList<Integer> primeFilter(int[] numberList) {
    ArrayList<Integer> primeNumbers = new ArrayList<Integer>();
    for(int value: numberList){
      ArrayList<Integer> factors = new ArrayList<Integer>();
      for(int i = 2; i <value; i++){
        if(value%i == 0){
          factors.add(i);
        }
      }
      if(factors.size() == 0){
        primeNumbers.add(value);
      }
    }
    return primeNumbers;
  }

  public static void main(String[] args) {
    PrimeDirective pd = new PrimeDirective();
    int[] numbers = {6, 29, 28, 33, 11, 100, 101, 43, 89};
    ArrayList<Integer> primeList = pd.primeFilter(numbers);
    System.out.println(primeList.toString());
  }
}
Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
zthomas.nc
  • 3,689
  • 8
  • 35
  • 49

0 Answers0