Help translating c++ code to java in the cutting sticks problem
<p>Im not used to code in java so i need help to translate this code to from c++ to java in a functional way. I tried it myself but the result was always 0. It is the CUTTING STICKS PROBLEM.</p>

<pre><code>#include &lt;iostream&gt;

#define MAXINT 2147483647
#define NCUTS 50
using namespace std;


int main() {

    int len;
    int nc; 
    int arr[NCUTS+2];
    int dp[NCUTS+2][NCUTS+2];

    while((cin &gt;&gt; len) &amp;&amp; (len != 0)) {
        cin &gt;&gt; nc;

        for(int i=0; i&lt;nc; i++) {
            cin &gt;&gt; arr[i+1];
        }

        arr[0] = 0;
        nc++;
        arr[nc] = len;

        for(int i=0; i&lt;=NCUTS+1; i++) {
            for(int j=0;j&lt;=NCUTS+1;j++) {
                dp[i][j] = MAXINT;
            }
        }

        for(int i=0; i&lt;=nc; i++) {
            dp[i][i] = 0;
            dp[i][i+1] = 0;
            dp[i][i+2] = arr[i+2] - arr[i];
        }

        for(int k=3; k&lt;=nc; k++) {
            for(int i=0; i&lt;=nc-k; i++) {
                for(int j=i+1; j&lt;=i+k-1; j++) {
                    if((dp[i][j] + dp[j][i+k] + arr[i+k] - arr[i]) &lt; dp[i][i+k]) {
                        dp[i][i+k] = dp[i][j] + dp[j][i+k] + arr[i+k] - arr[i];
                    }
                }
            }
        }
        cout &lt;&lt; "The minimum cutting is "&lt;&lt; dp[0][nc] &lt;&lt; "." &lt;&lt; endl;
    }
}
</code></pre>
