title: why a Chinese character takes one char (2 bytes) but 3 bytes?
body: <p>I have the following program to test how Java handle Chinese characters:</p>
  
  <pre><code>String s3 = "世界您好";
  char[] chs = s3.toCharArray();
  byte[] bs = s3.getBytes(StandardCharsets.UTF_8);
  byte[] bs2 = new String(chs).getBytes(StandardCharsets.UTF_8);
  
  System.out.println("encoding=" + Charset.defaultCharset().name() + ", " + s3 + " char[].length=" + chs.length
                  + ", byte[].length=" + bs.length + ", byte[]2.length=" + bs2.length);
  </code></pre>
  
  <p>The print out is this:</p>
  
  <p><strong><em>encoding=UTF-8, 世界您好 char[].length=4, byte[].length=12, byte[]2.length=12</em></strong></p>
  
  <p>The result are these:</p>
  
  <ol>
  <li><p>one Chinese character takes one <code>char</code>, which is 2 bytes in Java, if <code>char[]</code> is used to hold the Chinese characters;</p></li>
  <li><p>one Chinese character takes 3 <code>byte</code>s if <code>byte[]</code> is used to hold the Chinese characters;</p></li>
  </ol>
  
  <p>My questions are if 2 bytes are enough, why we use 3 bytes? if 2 bytes is not enough, why we use 2 bytes?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>My JVM's default encoding is set to UTF-8.</p>