I've been given a section of code written in C# that I have to migrate to Java. In C#, the code boils down to:
int foo = getFooValue();
UInt16 bar = 0x0080;
if((foo & bar) == 0)
{
doSomeCoolStuff()
}
Given that java doesn't have unsigned number types, how do I do this in Java?
intin this particular case (even though it's signed).65535foruint16). However, in this case your value is128which definitely fits normalint16int. The signed negative short will expand with two bytes of ones on the left, while the unsigned will expand with zeros.intin both C# and Java.