Does anyone know why I am getting an NullPointerException:Null error for this method?
public int[] checkISBN()
{
String letter;
int[] isbnCheck = new int[9];
for (int i = 0; i < 9; i++)
{
letter = isbn.substring(i,i+1);
isbnCheck[i] = Integer.parseInt(letter);
}
return isbnCheck;
This is the specs for this class:
check ISBN for correctness. The ISBN number (for books published before January 1 2007, and we will use this type of ISBN) is a series of 9 digits and one last digit or letter. The last entry is computed as follows: if (abcdefghi) are the first nine digit, compute a*1 + b*2 + c*3 + d*4 + e*5 + f*6 + g*7 + h*8 + i * 9 then compute the remainder of the division of the above sum by 11 (use the % operator). The result of this calculation is then the last digit of the ISBN. If the result of the calculation is 10, the last entry of the ISBN is X. Therefore, your method will check the ISBN for correctness and return true or false according to its findings.