Prime Directive Project Help

Good Evening! I’m having a bit of a problem with the Prime Directive project throwing an error that I can’t seem to fix. I’m sure it’s something simple that I have looked over more than once lol. I’m receiving the following error when compiling:

PrimeDirective.java:24: error: cannot find symbol
ArrayList primes = new Arraylist();
^
symbol: class Arraylist
location: class PrimeDirective
1 error

My code is:

import java.util.ArrayList;

public class PrimeDirective {

    public boolean isPrime(int number){

        if (number == 2) {

            return true;

        }

        else if (number < 2) {

            return false;

        }

        for (int i = 2; i < number; i++){

            if (number % i == 0) {

                return false;

            

            }

        }

        return true;

    }

    public ArrayList<Integer> onlyPrimes(int[] numbers){

    

    ArrayList<Integer> primes = new Arraylist<Integer>();

      

      for (int number : numbers){

        if (isPrime(number)){

          primes.add(number);

        }

      }

      return primes;

    }

    public static void main(String[] args) {

        PrimeDirective pd = new PrimeDirective();

        int[] numbers = {6, 29, 28, 33, 11, 100, 101, 43, 89};

        System.out.println(pd.onlyPrimes(numbers));

    }

}

What am I missing???

I think it’s the lower case L in list in your declaration.

Welcome to the forums :slight_smile:

1 Like

Yep, just posted the code to a friend on discord and as soon as I hit enter and it populated there I saw the lower case L and facepalmed. Thank you for the welcome!!!

1 Like