### Question:
Hex { public static byte[] fromHexString (String s) { int n = s.length()/2; byte[] tbr = new byte[n]; int strIndex = 0; String char2; for (int i=0;i<n;i++) { char2 = s.substring(strIndex, strIndex+2); tbr[i] = (byte) fromString(char2); strIndex+=2; } return tbr; }  static int fromString(String s); static byte[] fromHexString(String s); static String toPrint(byte[] bytes); static String toPrint(byte[] bytes, int offset, int length); static String toString(byte[] bytes); static String toString(byte[] bytes,int offset, int length);  }### Answer:
@Test public void testFromHexString() { String str = "0102030405060708090A0B0C0D0E0F10"; byte[] bytes = Hex.fromHexString(str); for (int i = 0; i < bytes.length; i++) { assertTrue(bytes[i] == (byte) (i + 1)); } String str2 = Hex.toString(bytes); assertTrue(str.equals(str2)); }