This is a question for the school assignment, so I do it this way.
In any case, I make a scanner using Stdin in the main method (Scanner stdin = new Scanner (System.in); this is a line), reading data from the txt specified when the program starts. This scanner works as expected basically, however I need to use it in a custom class that has the scanner as an argument:
public PhDCandidate(Scanner stdin) { name = stdin.nextLine(); System.out.println(name); //THIS NEVER RUNS preliminaryExams = new Exam[getNumberOfExams()]; for(int i = 0; i <= getNumberOfExams(); i++) { preliminaryExams[i] = new Exam(stdin.nextLine(), stdin.nextDouble()); } System.out.print("alfkj"); }
At this point, any call to the scanner will simply end the program, without any exceptions or errors. Only the .next () call works. I could make the program work, but it would be hacked, and I really donβt understand what is happening. I suspect that I am missing a very simple concept, but I am lost. Any help would be appreciated.
source share