Hi Guys,
I am having this error:
and it says that it is in the line:Code:Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
This is the whole code. This is used to generate a set of questions randomly.Code:int[] A = new int[questions.length];
Code:public void askQuestions(String[] questions, String[] answers) { int count = 0; int point = 0; // Create the arrays int[] A = new int[questions.length]; int[] B = new int[A.length]; // Create the counters int countA = A.length; int countB = 0; // adding the indexes to A for (int i = 0; i < A.length; i++){ A[i] = i; } while (countA > 0){ Random generator = new Random(); int pos = generator.nextInt(countA); // Adding the index of A at pos to B B[countB] = A[pos]; countB++; // Removing the index of A at pos from A for (int i = pos; i < A.length - 1; i++) { A[i] = A[i + 1]; } countA--; }


Reply With Quote


Bookmarks