Why no runtime error?

Write here if you have problems with your Java source code

Moderator: Board moderators

Post Reply
farsight
New poster
Posts: 7
Joined: Wed Aug 06, 2003 4:51 am

Why no runtime error?

Post 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;
}
}
xbeanx
Experienced poster
Posts: 114
Joined: Wed Jul 30, 2003 10:30 pm
Location: Newfoundland, Canada (St. John's)

Post 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.
veron
New poster
Posts: 29
Joined: Tue Jun 03, 2003 6:38 pm

Post 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.
Spike
New poster
Posts: 29
Joined: Mon Mar 18, 2002 2:00 am
Location: Washington State
Contact:

Post 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.
fpnc
System administrator
Posts: 201
Joined: Sun Oct 07, 2001 2:00 am
Location: Valladolid, Spain

Post 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.
Best regards,

Fernando N
Post Reply

Return to “Java”