Sieve of Erathostenes is work as follow:
First assume that all numbers is prime.
Starting from 2, crossing out all the numbers that is a multiple of two. Then, move to the next number that is not crossed out, and remove all multiple of this number, and so on... so, in the end what is left is the list of prime number.
So clearly, your code is not Sieve of Erathostenes, which you made an assumption that the list of prime is only 2,3,5,7
To check whether a number is a prime or not, we can have a more easy way, instead of using Sieve of Erathostenes, which is only suitable when you want to generate a list of prime numbers.
Pseudo Code:
boolean isPrime(int num){
for(int i = 2; i*i <= num ; i++){
if(num % i == 0){
return false;
}
}
return true;
}