Adding a short to a 2D short array element giving error in JAVA
<p>The code below gives the following error :</p>

<p>Error: C:\Users\Laptop\algs4\hello\Main.java:8: possible loss of precision</p>

<p>found   : int</p>

<p>required: short</p>

<pre><code>import java.util.* ; 
import java.math.* ; 
import java.io.* ; 
public class Main{
    public static void main(String[] args){
        short[][] arr = new short[1][2]; 
        short val = 9 ; 
        arr[0][0] = arr[0][0] + val ; 
    }
}
</code></pre>

<p>But the following gives no error . </p>

<pre><code>import java.util.* ; 
import java.math.* ; 
import java.io.* ; 
public class Main{
    public static void main(String[] args){
        short[][] arr = new short[1][2]; 
        short val = 9 ; 
        arr[0][0] += val ; 
    }
}
</code></pre>

<p>What maybe the reason for this ? </p>
