Null Pointer Exception on Object Array

Because in the for-each loop the variable sf is a local variable which is a copy of the reference in the array. You can alter it but it doesn’t alter the array or collection it comes from.

1 Like