My coding have no error but i don't understand why there is error when i run. Below are the complete exception:-
java.util.NoSuchElementException
Initializing population...
at java.util.StringTokenizer.nextToken(Unknown Source)
at Input.takeinput(Input.java:44)
at schedule.main(schedule.java:33)
Exception in thread "main" java.lang.IllegalArgumentException: bound must be positive
at java.util.Random.nextInt(Unknown Source)
at schedule.createpopulation(schedule.java:244)
at schedule.main(schedule.java:37)
Where does the exception really happen?
For the first error,here's the coding (Input.java:44)
File file = new File("input.txt");
Scanner scanner = new Scanner(file);
while(scanner.hasNextLine()){
String line = scanner.nextLine();
//StringTokenizer st = new StringTokenizer(line, ";");
//input student and sv
if(line.equals("student")){
nostud = 0;
while(!(line=scanner.nextLine()).equals("examiner")){
StudData[nostud] = new Student();
StringTokenizer st = new StringTokenizer(line, ";");
StudData[nostud].setName(st.nextToken());
StudData[nostud].setCode(st.nextToken());
StudData[nostud].setSvName(st.nextToken());
StudData[nostud].setSvCode(st.nextToken());
nostud++;
}
}
and (schedule.java:33)
input.takeinput();
For the second error.(schedule.java:44)
while(!flag){
int ex = r.nextInt(noexm);
and (schedule.java:37)
createpopulation();