title: Narrowing conversion from byte to char Java
body: <p>I read that although type byte occupies 8 bits of memory, and type char occupies 16 bits of memory, the conversion from byte to char is considered narrowing because byte is signed, while char is unsigned. I think this means that when we convert a type byte with a negative value to char, we lose the negative and so that is our loss of information and so the conversion is narrowing.</p>
  
  <p>I am trying to test this in a Java program.</p>
  
  <pre><code>public class Test
  {
    public static void main (String[] args)
    {
      byte num = -1;
      char test = (char)num;
      System.out.println(test);
    }
  }
  </code></pre>
  
  <p>I expected that printing test would output:</p>
  
  <pre><code>1
  </code></pre>
  
  <p>This would be -1 without the negative sign because char is unsigned. This in fact outputs:</p>
  
  <pre><code>?
  </code></pre>
  
  <p>Is there something wrong with my program or with my idea about converting byte to char?</p>