title: Java Convert Int to Hex and stick it in byte array element
body: <p>I've started learning a little java, and am trying to accomplish what is likely a very simply task but I'm struggling with it.</p>
  
  <p>Say I have a byte array:</p>
  
  <pre><code>byte[] test = {(byte) 0x0a, (byte) 0x01, (byte) 0x01, (byte) 0x0b};
  </code></pre>
  
  <p>and I want to change test[3], the last value which is currently the number 11 (0b), to something random.</p>
  
  <pre><code>Random generator = new Random();
  
  int newTest3 = generator.nextInt(255);
  </code></pre>
  
  <p>So, now I have some random number in newTest3. I want to convert this to hex (FF) and then place that into the last element of test, or test[3]. </p>
  
  <p>I couldn't find much to help me on this, and I literally just picked up java a couple hours ago, so any help would be outstanding! </p>
  
  <p>Thanks in advance :)</p>