把isPrime改成:
boolean isPrime(long checkNumber)
{
double root=Math.sqrt(checkNumber);
for(int i=2;i<=root;i++)
{
if(checkNumber%i==0)
{
return false;
}
}
                            return true;
}
注意看return true的位置

解决方案 »

  1.   

    class PrimeFinder
    {
    public static void main(String[] args)
    {
    long x=2;

    while(x<=100)
    {
    if(isPrime(x))
          {
          System.out.print(x++  );
          
          }
    }

    }
    static boolean isPrime(long checkNumber)
    {
    double root=Math.sqrt(checkNumber);
    for(int i=2;i<=root;i++)
    {
    if(checkNumber%i==0)
    {
    return false;
    }
    }
    return true;
    }
    }打印结果:23
      

  2.   

    ++,--都是针对整型的,对long型不支持.
      

  3.   

    zh
    /**
     * <p>Title: </p>
     * <p>Description: </p>
     * <p>Copyright: Copyright (c) 2004</p>
     * <p>Company: </p>
     * @author not attributable
     * @version 1.0
     */class PrimeFinder
    {
            public static void main(String[] args)
            {
                    long x=2;
                    PrimeFinder aa=new PrimeFinder();
                    while(x<=100)
                    {
                            if(aa.isPrime(x))
                          {
                                  System.out.print(x++  );                      }
                    }        }
                     boolean isPrime(long checkNumber)
                    {
                            double root=Math.sqrt(checkNumber);
                            for(int i=2;i<=root;i++)
                            {
                                    if(checkNumber%i==0)
                                    {
                                            return false;
                                    }                        }
                              return true;
                    }}
      

  4.   

    //楼主的意思是不是打印2-100之内的质数?
    class PrimeFinder
    {
    public static void main(String[] args)
    {
    int x=2;

    while(x<=100)
    {
    if(!isPrime(x))
          {
          System.out.println(x++  );
          
          }
     else
     x++;
    }

    }
    static boolean isPrime(int checkNumber)
    {
    double root=Math.sqrt(checkNumber);
    for(int i=2;i<=root;i++)
    {
    if(checkNumber%i==0)
    {
    return true;
    }
    }
    return false;
    }
    }