It uses the idea of Seive of Eratosthenes.

The code is basically does the following to find Prime Numbers :

1) Populate Array from 0 - > MAX

2) Find 1st Prime, which is 2

3) Delete all Multiple of 2, i.e set it to false

4) Find next prime, which is 3

5) Delete all multiple of 3

6) Repeat steps 4 - 6 until done.

I also use a little try and catch, just to provide as an example.