I’d created a program to my homework, i tried it to test on ideone.com, but i get an error:
Exception in thread "main" java.lang.NullPointerException
at Main.main(Main.java:83)
for every test(in elipse workin’ fine)
line 83:
String[] val = tab.split(" ");
line 82: // only for informational purpose
String tab = in.readLine();
line 78:// only for informational purpose
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
The scanner is greedily pulling in the full input on the first call to
nextInt. I recommend using either the scanner or the buffered reader–but not both. Having them both reading from the same stream is causing problems.Remove the scanner and change the way you grab the first number: