Categories
Question about an array of byte?
there is an array of byte ((3 235) , (225 7)). according to the int principle (this is 2 byte). how to convert a byte array to an int to get ((1003) , (2017))?
Answer the question
In order to leave comments, you need to log in
int is 4 bytes, not 2. But you can add like this:
int i = 0; byte b1 = 3; // 11 byte b2 = 5; // 101 i = i | b1; i = i << 8; i = i | b2; System.out.println(i);
Didn't find what you were looking for?
Ask a Question
731 491 924 answers to any question