list?.size()++There is no issue for the first part list?.size() at all, the safe navigation operator does it job and helps avoid NullPointerException. The issue is the ++ part. Suppose list is null, list?.size() will also be null. Then null++ will generate an error
“java.lang.NullPointerException: Cannot invoke method next() on null object”.
No comments:
Post a Comment