How to declare 32-bit integers in Java?

I am looking for a Java application running on 32 - bit and 64 - bit systems, which mainly deals with IP addresses These IP addresses are kept as integers, and normal types waste a lot of memory on 64 bit platforms (yes, memory usage has proved to be a problem) Even on x64 architecture, how to declare that 32-bit integer values remain at 32 bits?

Because I am a novice in Java, if there is a built-in type that has been designed to handle IP addresses, please point out me at any time;)

Solution

Java has a specific data type width to achieve portability Even on 64 - bit platforms, integers are 32 - bit wide The Java language specification status is quiet clear (in my opinion, it is slightly more readable):

This can be said to be due to many portability problems found in C. they have different widths (even coding, such as two complements, one complement and symbol / amplitude). These integers are what Java wants to avoid, especially because it means that multiple different platforms can be run as much as possible

As for the built-in types used to handle IP addresses, Java has inet4address and inet6address, depending on your needs (and their common ancestor, InetAddress)

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>