Search code examples
javaprimitive

In Java does anyone use short or byte?


Apart from using (byte[]) in streaming I don't really see byte and short used much. On the other hand I have seen long used where the actual value is |100| and byte would be more appropriate. Is this a consequence of the relative inexpensive nature of memory now or is this just minutia that developers needn't worry about?


Solution

  • They are used when programming for embedded devices that are short on memory or disk space. Such as appliances and other electronic devices.

    Byte is also used in low level web programming, where you send requests to web servers using headers, etc.