title: How to bundle a byte array in java from different types
body: <p>I want to built a UDP based Protocol which is able to send a file from a client to an server. The restriction is that the data which is send is exactly &lt;x> bytes big. For example one packages should contain a 32-bit sessionnumber, a 8-bit packagenumber and a 10-byte large word in ASCII-Code. </p>
  
  <p>I know that I have to initialize a byte-array which is in this case 15 bytes long but how can I write into it that I have the form I need?</p>
  
  <pre><code>byte[] array = new byte[15];
  </code></pre>
  
  <p>I tried to write "starting" in ASCII in the byte-array:</p>
  
  <pre><code>array[6] = 115;
  array[7] = 116;
  array[8] = 97;
  array[9] = 114;
  array[10] = 116;
  array[11] = 105;
  array[12] = 110;
  array[13] = 103;
  </code></pre>
  
  <p>But it's not working how it should. Please give an explanation with your answer because I want to understand and learn with it.</p>