Search:

Type: Posts; User: Junky

Search: Search took 0.08 seconds.

  1. Re: Practicing before taking a class(Exception in thread "main" java.lang.NullPointer

    I have just taken the code you posted above, fixed the for loop and ran it. It throws a divide by zero error. I'm damned if I know how you are capable of running the code you posted without getting...
  2. Re: Practicing before taking a class(Exception in thread "main" java.lang.NullPointer

    It might compile but when you run the code it will throw the out of bounds exception. If it doesn't then the code you are running and the code you posted are different. Please post the latest version...
  3. Re: Practicing before taking a class(Exception in thread "main" java.lang.NullPointer

    Another problem

    int[] primes = new int[whichPrime];
    return primes[whichPrime];

    This will cause an ArrayIndexOutOfBoundsException. If you create an array with a size of 10 then the valid...
  4. Re: Practicing before taking a class(Exception in thread "main" java.lang.NullPointer

    The code you posted above doesn't even compile.

    for (ndx = 0; ndx < numPrimes && testPrime % primes[ndx] != 0; ndx++
    {
    ;
    }

    Incomplete for loop statement. You also have a missing statement...
  5. Re: Practicing before taking a class(Exception in thread "main" java.lang.NullPointer

    String s = null;
    System.out.println(s.length());

    The above code will generate a null pointer exception because the s variable is null. On line 40 of your code you have done something similar. You...
Results 1 to 5 of 5