在真实应用程序中使用短和字节原始类型的人? [英] Anyone using short and byte primitive types, in real apps?

查看:102
本文介绍了在真实应用程序中使用短和字节原始类型的人?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自2004年以来,我一直使用Java编程,主要是企业和Web应用程序。但我从未使用字节,除了玩具程序,只是为了知道这些类型是如何工作的。即使在100次的 for循环中,我们通常也会使用 int 。而且我不记得我是否遇到过任何使用 byte short 的代码,而不是一些公共API和框架。

I have been programming in Java since 2004, mostly enterprise and web applications. But I have never used short or byte, other than a toy program just to know how these types work. Even in a for loop of 100 times, we usually go with int. And I don't remember if I have ever came across any code which made use of byte or short, other than some public APIs and frameworks.

是的我知道,在内存节省实际上很重要的情况下,您可以使用字节来节省大型阵列的内存。有人关心练习吗?或者只是书中的内容。

Yes I know, you can use a short or byte to save memory in large arrays, in situations where the memory savings actually matters. Does anyone care to practice that? Or its just something in the books.

[已编辑]

使用<用于网络编程和套接字通信的em> byte 数组是一种非常常见的用法。感谢Darren指出这一点。那么怎么样?瑞安,举了一个很好的例子。谢谢,Ryan。

Using byte arrays for network programming and socket communication is a quite common usage. Thanks, Darren, to point that out. Now how about short? Ryan, gave an excellent example. Thanks, Ryan.

推荐答案

请记住,Java也用在移动设备上,而内存则受到更多限制。

Keep in mind that Java is also used on mobile devices, where memory is much more limited.

这篇关于在真实应用程序中使用短和字节原始类型的人?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆