且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

原始数组与 ArrayList

更新时间:2023-02-26 22:14:14

原始数组效率更高,因为它们不需要包装对象.Guava 具有由原始数组支持的 List 实现(例如:Ints.asList(int[])),也许这对您来说可能是一个合理的解决方案:获得集合的强大功能,但仅在您真正需要它们时才使用对象.

Primitive arrays are much more efficient, as they don't require wrapper objects. Guava has List implementations that are backed by primitive arrays (example: Ints.asList(int[])), perhaps that could be a reasonable solution for you: get the power of a collection but only use Objects when you actually need them.