Question: I have a **uint8** *(unsigned 8 bit integer)* coming in from a UDP packet. Java only uses signed primitives. How do I parse this data structure correctly with java?

Answer: 
Simply read it as as a byte and then convert to an int.

```
byte in = udppacket.getByte(0); // whatever goes here
int uint8 = in & 0xFF;

```

The bitmask is needed, because otherwise, values with bit 8 set to 1 will be converted to a negative int. Example:

```
This:                                   10000000
Will result in: 11111111111111111111111110000000

```

So when you afterwards apply the bitmask 0xFF to it, the leading 1's are getting cancelled out. For your information: `0xFF == 0b11111111`
`0xFF & number` will treat the number as unsigned byte. But the resultant type is `int`