File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed
Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change 713713 + 有性能代价!一定会创建Iterator ,对于安卓开发,不建议如此。
714714 + 不能在for - each语法中进行remove,用Iterator 遍历时,能remove
715715 + 遍历过程中替换原有元素
716- + Parallel iteration
716+ + Parallel iteration
717+ + Item 47 : Know and use the libraries
718+ + don' t reinvent the wheel
719+ + 视野!
720+ + Item 48: Avoid float and double if exact answers are required
721+ + float和double设计为用于科学计算,“精确近似”,需要确切结果的,不要使用,例如:货币相关!应该使用BigDecimal, int, 或者long。
722+ + BigDecimal使用有些不方便,性能也比primitive类型低
723+ + Item 49: Prefer primitive types to boxed primitives
724+ + 两种类型的区别
725+ + boxed类型,除了包含数值外,还有不同的唯一标示,即值一样,对象可以不一样,这一点很重要!
726+ + boxed类型,比primitive类型多一个值,null
727+ + boxed类型,时间、空间效率均低一些
728+ + caveats
729+ + 有些操作会auto-unbox,例如:加减乘除,大小比较,但判等(`==`)不会!
730+ + Applying the `==` operator to boxed primitives is almost always wrong.
731+ + boxed类型,值为null时,会unbox为什么呢?会抛出`NullPointerException`
732+ + 当boxed和primitive出现在同一个运算中,boxed类型会auto-unbox(包括判等)
733+ + 大量重复的box/unbox会导致性能大幅下降
734+ + 使用场景与注意事项
735+ + 放到标准集合里面,必须是boxed类型
736+ + 作为类型参数(泛型),必须是boxed类型
737+ + auto-box是安全的,也能省去繁琐的代码,但是auto-unbox则可能引起隐蔽的错误
You can’t perform that action at this time.
0 commit comments