Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Java Language
Expertise: Beginner
Jun 6, 2000



Building the Right Environment to Support AI, Machine Learning and Deep Learning

DWORD Equivalent

I'm trying to translate from VC++ to Java. Can you declare a variable DWORD in Java? If not, what is the Java equivalent?

Also, what is the equivalent for HINSTANCE?

Java differs from C and C++ in that all of its fundamental data types have specified sizes that are guaranteed to be the same across all platforms. In C, the size of an integer can vary from compiler to compiler and platform to platform. When Microsoft moved from 16-bit DOS and Windows 3.1 to 32-bit Windows 95 and NT, they tried to abstract the fundamental types in order to facilitate the maintenance of a single code-base for different memory architectures. Therefore, a DWORD may be represented by a different native C type on Windows 95 for Intel processors and NT 4.0 for Alpha processors.

There is no need to abstract the fundamental data types because Java defines a fixed size for all of its data types. To answer your first question: no, you cannot declare a variable as a Visual C++ DWORD in Java. The Microsoft types are also ill-designed because a WORD is actually a 16-bit unsigned integer value in 32-bit Windows 95, where you would expect a WORD to be a 32-bit unsigned integer value. A DWORD is a 32-bit unsigned integer value. Java does not support unsigned integer types other than char, which you shouldn't think of as an integer type, so there is no Java equivalent to a DWORD. You could use an int, which is 32 bits, if you are only concerned about bit values—or a long, which is 64 bits, if you want to easily manipulate the range of 32 bit unsigned values.

HINSTANCE is usually a void pointer, for which the closest Java analog is an Object reference.

DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date