Note that there are some explanatory texts on larger screens.

plurals
  1. POwhy's this program giving a runtime error on jcreator but not on netbeans?
    primarykey
    data
    text
    <p>This is my solution for sphere's online judge <a href="https://www.spoj.pl/problems/PALIN/" rel="nofollow noreferrer">palin problem</a>. It runs fine on Netbeans, but the judge is rejecting my answer saying it gives a RuntimeError. I tried it on JCreator and it says:</p> <pre><code>Exception in thread "main" java.lang.NumberFormatException: For input string: "" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48) at java.lang.Integer.parseInt(Integer.java:468) at java.lang.Integer.parseInt(Integer.java:497) at Main.main(Main.java:73) </code></pre> <p>I'm not passing an empty string for it to parse, why is this?</p> <p>The code:</p> <pre><code>import java.io.*; import java.util.*; class Main { public static int firstPalinLargerThanNum(int num){ int foundPalin =0; int evalThisNum = ++num; while (true){ if (isPalin(evalThisNum)) break; evalThisNum++; } foundPalin = evalThisNum; return foundPalin; } public static boolean isPalin(int evalThisNum){ boolean isItPalin = false; int dig=0; int rev=0; int n = evalThisNum; while (evalThisNum &gt; 0) { dig = evalThisNum % 10; rev = rev * 10 + dig; evalThisNum = evalThisNum / 10; } if (n == rev) { isItPalin=true; } return isItPalin; } public static void main(String args[]) throws java.lang.Exception{ BufferedReader r1 = new BufferedReader(new InputStreamReader(System.in)); /*BufferedReader r1 = new BufferedReader (new FileReader(new File ("C:\\Documents and Settings\\Administrator\\My Documents\\NetBeansProjects\\Sphere\\src\\sphere\\sphere\\PALIN_INPUT.txt")));*/ String read = r1.readLine(); int numberOfTestCases = Integer.parseInt(read); for (int i=0; i&lt;numberOfTestCases;i++){ read = r1.readLine(); if (read!=null){ int num = Integer.parseInt(read); System.out.println(firstPalinLargerThanNum(num)); } } } } </code></pre> <p>Input:</p> <pre><code>2 808 2133 </code></pre> <p>line 73 is: <code>int num = Integer.parseInt(read);</code></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload