Help with

Hi, I’m in the middle of doing the Prime Directive project on Learn Java. No matter how many times I check my code for typos or errors it won’t run on java PrimeDirective on the terminal. When I use javac it says I have 13 errors!
Here is my code below:

import java.util.ArrayList;
class PrimeDirective {
  // Add your methods here:
  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)) {

  return primes;

  public static void main(String[] args) {

    PrimeDirective pd = new PrimeDirective();
    int[] numbers = {6, 29, 28, 33, 11, 100, 101, 43, 89};


Any Help or suggestions would be great. Thanks in advance.

Hello, @system4677739580.

Welcome to the forum.

It will be much, much easier to help you if you re-post your code following the guidelines below.

THANK YOU @patrickd314 for this!!

Code that is posted without the indentations, whitespace and special characters preserved, is very difficult to read, and cannot easily be tested by those trying to help you.

The Codecademy forum provides a quick and easy way to post properly-formatted code. All you need to do is look for the </> icon in the menu bar which appears at the top of the text box while you type.


Press Enter to go to a blank line, click that icon, and you will see this:


Just copy and paste your code directly from the editor into that highlighted portion, and all of the nicely-readable formatting will be preserved! Moreover, it will be in a format that can be directly copied and pasted into an IDE for testing.

The same icon can be used for highlighting small code snippets in-line for clarity.

Have a look at each closing } and check whether they are all in the right place. If you click on each } it will show which opening { it is connected to. It says you have 13 errors but in reality you only have one.