Details: After select to start a new prediction, an java.lang.ArrayIndexOutOfBoundsException is thrown Reproducible steps 1. Enter "1" to select "Office Box Prediction" in [System Home] 2. Enter "1" to select "Start New Prediction" in [Office Box Prediction] Expected results: - At step (2), no exception or error should be shown and parameters for prediction can be input to process prediction Actual results: - At step (2), java.lang.ArrayIndexOutOfBoundsException is thrown and the program is interrupted Detailed console output: >> [Office Box Prediction] >> >> 1 Start New Prediction >> 2 Back to Home >> >> Please enter your option [1/2] >> 1 >> >> Enter genre, director, leading actor, leading actress and budget of new movie to predict box office (seperate by comma): Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4 >> at movieRating.PredictSys.doNewPrediction(PredictSys.java:23) >> at movieRating.PredictSys.enter(PredictSys.java:64) >> at movieRating.Main.main(Main.java:24) Note / Additional information - This exception does not appear in recommendation feature
Root cause - Scanner.nextInt method(PredictSys.java:62) does not read the newline character ("\n") entered by hitting "Enter", so after that the call to Scanner.nextLine(PredictSys.java:18) returns after reading that "\n" but before reading parameter for prediction How to fix - Added to consume the newline character before calling Scanner.nextLine to read parameter input Expected behavior - No exception or error should be shown and parameters for prediction can be input to process prediction Potential affected areas - PredictSys Affected versions - >=v2 Test cases 1. Enter "1" to select "Office Box Prediction" in [System Home] 2. Enter "1" to select "Start New Prediction" in [Office Box Prediction] Test result - At step (2), no exception or error is shown and parameters for prediction can be input to process prediction