6

I have few datatypes used in C# that I need to translate to Java.

uint, Int16, UInt16, Nullable<Int16>

What will be the appropriate datatype for these in Java?

0

3 Answers 3

6

Although the link provided by x2 is good, it's not all that useful when dealing with unsigned primitives. For example: the range of an int is 2,147,483,648 to 2,147,483,647 (which is the same in both languages), but the range of C#s uint is 0 to 4,294,967,295. Java doesn't have a similar primitive type, so you'd have to use something that contains that range (in this case, a long).

If you are only worried about 1-way compatibility (C# to Java) these should work:

  • c# --> java
  • uint --> long
  • Int16 --> short
  • UInt16 --> short
  • Nullable --> look into the classes that wrap the primitive types (i.e. Integer wraps an int)

EDIT:: I just found this article on MSDN about the differences between the data types in the two languages.

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

Comments

5

Data type equivalents between Java and C#. Hope you can find it out.

enter image description here

Comments

2

Chek it out

1 Comment

Link has rotten. Please don't give link-only answers. It's always better to give full or short answer with a link to a source.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.