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;
}
}
Why no runtime error?
Moderator: Board moderators
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.
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.