Considering the following for-each loop
String S = "";
byte[] sendingByte;
List<Integer> lst = new ArrayList<Integer>();
try {
ReadHoldRegisters(lst, 1, 1, 10);
for (int value : lst) {
S = S + String.format("%02x ", value);
}
etWrite.setText(S);
} finally {
// send modbus rtu byte[] array to USB serial port
}
Where ReadHoldRegisters generates a CRC16 ArrayList of Integer and that int in Java is a signed value
How can I allocate the int values inside the for-each loop into byte[] sendingByte array?