# Prime Directive projective - need help with "illegal start of expression" error

For the life in me, I can’t figure out this error. I even used a video tutorial to check. My code seems fine. Yet, I can’t get past this error.

Here’s the code:

``````// Import statement:
import java.util.ArrayList;

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 i : numbers) {
if (isPrime(i) == true) {
}
}
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.isPrime(6));
}

}
``````

The “illegal start of expression” error starts at this line:

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

If I remove that whole section of the code, the error then comes from this line:

``````public static void main(String[] args)
``````

Which is Codecademy’s own writing. But before adding anything to it. But if I take out everything I added except for the import statement, there’s zero issue.

``````// Import statement:
import java.util.ArrayList;

class PrimeDirective {

public static void main(String[] args) {

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

}

}
``````

Obviously, I’m doing something wrong, but I cannot find it! I worked on this for much of last night, tried googling it, looking for similar topics in the forums, YouTube… I’m stumped. Nothing looks wrong here, but something is.

You are missing a `}` at the end of the `isPrime` method (so there’s an error on a line afterward that has stuff on it).

``````  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;
} // <- you forgot this one
}
``````
2 Likes

Yes, I figured it out just seconds ago. Thank you for answering, though.