I have typed this code exactly the same way on my last program and now I am getting the following error!
Exception in thread "main" java.lang.NullPointerException
at Survey.enterQuestions(Survey.java:21)
at SurveyTest24.main(SurveyTest24.java:13)
Java Result: 1
Here is my code:
import java.util.*; public class Survey { Scanner in = new Scanner(System.in); private String surveyTitle; private static int CurrentID = 0; // holds the current respondent Id private int[][] Responses; private String[] Questions; public final static int MAX_RESPONSES = 10; public final static int MAX_QUESTIONS = 10; public final static int PRINT_ALL = -1; Survey(String title) { surveyTitle = title; // displaySurveyResults(); } public void enterQuestions() { for (int i = 0; i < Questions.length; i++) { System.out.println("Please enter a question! "); Questions[i] = in.nextLine(); } } public final void displaySurveyResults() { System.out.printf(surveyTitle); } // Print bar chart for each question private void displayQuestionStats(int qNumber){ } private void logResponse(int ID, int qNumber, int response){ } }