title: Converting String to UTF-8 byte array returns a negative value in Java
body: <p>Let's say I have a byte array and I try to encode it to UTF_8 using the following</p>
  
  <pre><code>String tekst = new String(result2, StandardCharsets.UTF_8);
  System.out.println(tekst);
  //where result2 is the byte array
  </code></pre>
  
  <p>Then, I get the bytes using getBytes() with values from 0 to 128</p>
  
  <pre><code>byte[] orig = tekst.getBytes();
  </code></pre>
  
  <p>And then, I wish to do a frequency count of my byte[] orig using the ff:</p>
  
  <pre><code>int frequencies = new int[256];
  
  for (byte b: orig){
      frequencies[b]++;
  }
  </code></pre>
  
  <p>Everything goes well till I encounter an error which states</p>
  
  <pre><code>java.lang.ArrayIndexOutOfBoundsException: -61
  </code></pre>
  
  <p>Does that mean that my byte still contains negative values despite converting it to UTF-8? Is there something wrong that I'm doing? Can someone please give me clarity on this cause I'm still a beginner on the subject. Thank you.</p>