ushort equivalent

4.3k views Asked by At

I have an application in C# that I'm trying to convert to java. The C# app has a few variables that are of type ushort. Is there an equivalent in java?

Thank you

2

There are 2 answers

0
John Feminella On BEST ANSWER

The closest equivalent in terms of size is char, since Java doesn't have unsigned types, but it's overloaded in Java to provide additional semantics related to individual characters. In general, just pick the next largest integral type (int, in this case). (You're not the only one who wants it, though.)

0
unwind On

As you may be aware, Java has no unsigned numbers. This means you're going to have to go with another solution. It's generally easiest to just use the next larger type in cases like these, such as int (which is simply a 32-bit signed integer).