編寫高質量代碼:改善Java程序的151個建議 --[26~36]

提防包裝類型的null值 public static int testMethod(List<Integer> list) { int count = 0; for (Integer i : list) { count += (i != null) ? i : 0; } return count; }public static int testMethod(List<Integer> list)
相關文章
相關標籤/搜索