Page 1 of 1

Why no runtime error?

Posted: Thu Sep 04, 2003 10:46 pm
by farsight
Shouldn't this code give me runtime error from the judge?
I get WA.!!!!!


import java.io.*;
import java.util.*;


class Main {


public static void main(String args[]) throws Exception {
int i = 1/0;
}
}

Posted: Sat Sep 06, 2003 3:47 pm
by xbeanx
I don't think you can even get a runtime error with JAVA here. It always comes back WA.

For some problems, I was parsing the input wrong, and where it should have been saying it was a runtime error, it was giving me a wrong answer. It took me forever to find the problem.

Posted: Sun Sep 07, 2003 9:53 am
by veron
Yah,it's should be run time error.I think it's a problem for new java developer who face this type ERROR.

Ofcourse I agree with you but I can't say what the real solution on this.

Posted: Fri Sep 26, 2003 12:15 am
by Spike
The problem lies with how they run the code. You're getting a wrong answer because it's printing out the error message. It doesn't throw errors back to the operating system like C or C++ code. It just keeps it in the Java environment.

So basically, the only thing that the operating system sees when Java encounters an error is a little print out on the screen, whereas C and C++ actually throw errors.

Posted: Fri Sep 26, 2003 3:25 pm
by fpnc
Spike is right, and the same happens with Pascal. The only way to change this would be to parse output, but this would be really a big change in the system and we cannot do it now.