1

i try :

byte[] Data = { 0xA3, 0x34, 0x33, 0x33, 0x00};

but at "0xA3" it said "required byte found int",so what's problem here ?

2
  • bytes range from -128 to 127. 0xA3 is 163. Commented Mar 22, 2016 at 3:14
  • @paulsm4 -128 to 127. Commented Mar 22, 2016 at 3:15

2 Answers 2

2

0xA3 is 163 which is out of bounds for byte which I think can be -128 -> +127.

You can find more details here

Sign up to request clarification or add additional context in comments.

3 Comments

i do that in C#, so in JAVA what i need to do ?
I think you are looking for an unsigned byte? You might find something here.
@HảiDuyNguyễn Cast it to byte: byte[] Data = { (byte)0xA3, 0x34, 0x33, 0x33, 0x00};
1

at "0xA3" it said "required byte found int", so what's problem here

The problem is that the range of a byte in Java is -128..127.

The solution is that you need to write a (byte) cast in front of 0xA3.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.