JavaScript to standard Java conversion issue
<p>I have a JavaScript Method and I need to convert this in standard Java, however I have a little problem with the lines</p>

<pre><code>if (jsum) sum += bj;
jsum=!jsum;
</code></pre>

<p>and</p>

<pre><code>return x &lt; 0.0 &amp;&amp; (n &amp; 1) ? -ans : ans;
</code></pre>

<p>That shows the error: <em>the operator is undefined</em>.
I know that I can't use this syntax in Java, but I haven't understood what is the right syntax to use to maintain the original purpose without issues</p>

<p>the full JS method is</p>

<pre><code>function bessel_fkb(n,x)
{ 
    if (n == null || n.length == 0) return "n not specified";
    var iac = 40.0;     
    var bigno = 1.0e10;
    var bigni = 1.0e-10;
    var j,jsum,m,ax,bj,bjm,bjp,sum,tox,ans;
    ax=Math.abs(x);
    if (ax == 0.0) return 0.0;
    else if (ax &gt; n) {
        tox = 2.0/ax;
        bjm=BesselJ0(ax);
        bj=BesselJ1(ax);
        for (j=1;j&lt;n;j++) {
            bjp=j*tox*bj-bjm;
            bjm=bj;
            bj=bjp;
        }
        ans=bj;
    } else {
        tox=2.0/ax;
        if (Math.sqrt(iac*n) &gt;= 0)
            m=2*((n + Math.floor(Math.sqrt(iac*n))) / 2);
        else
            m=2*((n + Math.ceil(Math.sqrt(iac*n))) / 2);
        jsum=0;
        bjp=ans=sum=0.0;
        bj=1.0;
        for (j=m;j&gt;0;j--) {
            bjm=j*tox*bj-bjp;
            bjp=bj;
            bj=bjm;
            if (Math.abs(bj) &gt; bigno) {
                bj *= bigni;
                bjp *= bigni;
                ans *= bigni;
                sum *= bigni;
            }
            if (jsum) sum += bj;
            jsum=!jsum;
            if (j == n) ans=bjp;
        }
        sum=2.0*sum-bj;
        ans /= sum;
    }
    return x &lt; 0.0 &amp;&amp; (n &amp; 1) ? -ans : ans;     
}
</code></pre>

<p>My Full Java conversion attempt is:</p>

<pre><code>public double bessel_fkb(double n, double x)
    { 
        double iac = 40.0;      
        double bigno = 1.0e10;
        double bigni = 1.0e-10;
        double jsum,m,ax,bj,bjm,bjp,sum,tox,ans;
        ax=Math.abs(x);
        if (ax == 0.0) return 0.0;
        else if (ax &gt; n) {
            tox = 2.0/ax;
            bjm=BesselJ0(ax);
            bj=BesselJ1(ax);
            for (int j=1;j&lt;n;j++) {
                bjp=j*tox*bj-bjm;
                bjm=bj;
                bj=bjp;
            }
            ans=bj;
        } else {
            tox=2.0/ax;
            if (Math.sqrt(iac*n) &gt;= 0)
                m=2*((n + Math.floor(Math.sqrt(iac*n))) / 2);
            else
                m=2*((n + Math.ceil(Math.sqrt(iac*n))) / 2);
            jsum=0;
            bjp=ans=sum=0.0;
            bj=1.0;
            for (int j=(int)m;j&gt;0;j--) {
                bjm=j*tox*bj-bjp;
                bjp=bj;
                bj=bjm;
                if (Math.abs(bj) &gt; bigno) {
                    bj *= bigni;
                    bjp *= bigni;
                    ans *= bigni;
                    sum *= bigni;
                }
                if (jsum) sum += bj;
                jsum=!jsum;
                if (j == n) ans=bjp;
            }
            sum=2.0*sum-bj;
            ans /= sum;
        }
        return x &lt; 0.0 &amp;&amp; (n &amp; 1) ? -ans : ans;     
    }
</code></pre>
