7.

Although most of the operations in SDES could be performed on bytes, SDES.java mainly uses ints. That's because Java operations on bytes produce int results which would have to be cast back to byte to be stored in a byte. Using int eliminates a lot of casts. Consider this code:
byte a = 1, b = 2, c;
c = a ^ b; // a XOR b
That will not compile; the javac error message is:
Incompatible type for =. Explicit cast needed to convert int to byte.
c = a ^ b; // a XOR b
^
1 error
To eliminate the error, use a cast:
c = (byte) (a ^ b); // a XOR b
No comments:
Post a Comment
comment.........