3 ms·
I am not a Java developer by trade, but I do a lot of C# stuff and the languages are somewhat similar. So with that in mind I imagine a byte type being useful
by wsc981 6y ago
I am not a Java developer by trade, but I do a lot of C# stuff and the languages are somewhat similar.
So with that in mind I imagine a byte type being useful for reading / writing binary formats [0] (e.g. for sending small amounts of data over a network). A byte or short type can also be useful for using bitfields [1]. In some use cases you might want to use a small type to store the flags (e.g. if you don't need 32 flags, it seems a waste to use a Int32 type).
---
[0]: https://www.codejava.net/java-se/file-io/how-to-read-and-write-binary-files-in-java https://www.codejava.net/java-se/file-io/how-to-read-and-wri...
[1]: https://en.wikipedia.org/wiki/Bit_field https://en.wikipedia.org/wiki/Bit_field
- metters 6y agoyes you are right, I totally forgot about byte-arrays for reading files. That still leaves short...