So,
I am trying to solve some problems in JavaScript, and getting Compilation errors I
don't understand. I have submitted a working solution for TEST, and now am trying to
use that basic model to address another problem, ARDA1. I think my problem really
doesn't have anything to do with specifics of that problem.
The error message I was getting is:
[quote]js: uncaught JavaScript runtime exception: TypeError: Cannot
call method "split" of null[/quote]
The first line of problem input has two integers.
So, to try to narrow the problem down, I simply submitted this:
[code]importPackage(java.io);
importPackage(java.lang);
var reader = new BufferedReader(new InputStreamReader(System['in']));
var line = reader.readLine();
var ary = line.split(' ');
var N1 = parseInt(ary[0]);
var N2 = parseInt(ary[1]);
var gMap = [];
System.out.println("WRONG ANSWER");[/code]
Thinking that should definitely compile and give WA, but it also gives same error:
[quote]js: uncaught JavaScript runtime exception: TypeError: Cannot
call method "split" of null[/quote]
I'm only calling readLine() once, so it must be returning null on the very first
call, right? Hard to go forward from here. I tried putting in a loop, thinking maybe
it returns null on first call, but is OK after that:
[code]
importPackage(java.io);
importPackage(java.lang);
var reader = new BufferedReader(new InputStreamReader(System['in']));
var line;
while (true) {
line = reader.readLine();
if (line !== null)
break;
}
var ary = line.split(' ');
var N1 = parseInt(ary[0]);
var N2 = parseInt(ary[1]);
var gMap = [];
System.out.println("WRONG ANSWER");
[/code]
This seems to take a very long time "compiling", then ultimately ends showing a
compilation error, but when you click on the link for the error, nothing shows.
HELP!?!? What is going on here?