How do i explain this code to a class of Java Card Beginners in a way they will understand it perfectly:
private void getBalance(APDU apdu) {
byte[] buffer = apdu.getBuffer();
// inform system that the applet has finished
// processing the command and the system should
// now prepare to construct a response APDU
// which contains data field
short le = apdu.setOutgoing();
if (le < 2) {
ISOException.throwIt((byte) 0x6A86);
}
// informs the CAD the actual number of bytes
// returned
apdu.setOutgoingLength((byte) 2);
// move the balance data into the APDU buffer
// starting at the offset 0
buffer[0] = (byte) (balance >> 8);
buffer[1] = (byte) (balance & 0xFF);//How do i explain what happens here
// send the 2-byte balance at the offset
// 0 in the apdu buffer
apdu.sendBytes((short) 0, (short) 2);
}