0

I want to create one byte array which should be able to handled the unsigned values. I have gone through this link on stack overflow. Can we make unsigned byte in Java.. It is mentioned in the answer that Java does not allow to express 244 as a byte value, as would C I want to have my byte array like this that byte [0] should have a value 239 and byte[1] should have a values as 245.

As per the documentation it is mentioned that we can only save value in a range-128 to 128 in byte.. how should i solve this problem?

Community
  • 1
  • 1
AndroidDev
  • 45
  • 1
  • 9
  • Have you used Guava's `UnsignedByte` http://google.github.io/guava/releases/snapshot/api/docs/com/google/common/primitives/UnsignedBytes.html ? – Boris Pavlović Nov 28 '16 at 12:40
  • 1
    No.. I havent tried this.Will check now. Thanks for immediate response. – AndroidDev Nov 28 '16 at 12:43
  • 1
    Did you understand what the linked question was about? Signed / unsigned is about human representation. Writing something like `byte b = (byte)239;` will result in the same **bits** in `b` as `unsigned byte b = 239;`. – Kayaman Nov 28 '16 at 12:57

0 Answers0