1. Buka NetBeans

2.Buat Project baru dengan nama “Prima” (tanpa tanda kutip “”)

3.Copy and Paste this code

package prima;

 // @author HaPe (HaPe Studios)

public class Prima {

     // @param args the command line arguments

    public static void main(String[] args) {
        // TODO code application logic here
        int numb, div, total = 0;
        for(numb = 1; numb < 100; numb++){
            int x = 0;
            for (div = 1; div < 100;div++){
                if (numb % div == 0){
                    x++;
                }
            }
            if ((x==2)&&(numb!=1)){
                System.out.println(numb+" adalah bilangan PRIMA");
                total++;
            }
        }
        System.out.println("nTotal bilangan prima adalah "+total);
    }
}

4. Run