privateintcount=0;
privateintn;
//用于判断一个数是不是素数
publicbooleanjudge(intnumber){
for(inti=2;i<=Math.sqrt(number);i++){
if(number%i==0){
returnfalse;
}
}
returntrue;
}
//用于处理某一范围的数据
publicvoidhandle(intstartNumber,intendNumber){
for(inti=startNumber;i<=endNumber;i++){
if(this.judge(i)==true){
this.count++;
}
}
}
publicvoidshow(){
System.out.println(“count=”+count);
}
}
=====================================================================
packagebbb;
publicclassPrimeNumberTest{
publicstaticvoidmain(String[]args){
PrimeNumberpn=newPrimeNumber();
pn.handle(101,200);
pn.show();
}
}