Your logic for finding prime numbers is incorrect.
Right now, what your code does is: 1. Iterate on all the integers up to N 2. Find any integer that N can't be divided by, and add them to the list. This has nothing to do with prime numbers.
Instead, your code should do something like: 1. Iterate on all the integers up to N 2. For each of these integers (let's say M), run a sub-loop iterating on all integers below it, and checking if none of those integers can divide M. If the sub-loop finishes without finding a divider of M, add M to the list - it's a prime number (can't be divided by any integer except 1 and itself).
Simple code for checking if a number (2 or above) is prime:
public boolean isPrime(int num)
{
for (int i = 2; i < num; ++i)
{
if (num % i == 0)
{
return false;
}
}
return true;
}
There are many optimisations for this and it's a world by itself.