unmodifiable

Java unmodifiable array

本秂侑毒 提交于 2019-11-27 05:54:38
问题 final Integer[] arr={1,2,3}; arr[0]=3; System.out.println(Arrays.toString(arr)); I tried the above code to see whether a final array's variables can be reassigned[ ans :it can be].I understand that by a final Integer[] array it means we cannot assign another instance of Integer[] apart from the one we have assigned initially.I would like to know if whether it is possible to make the array variables also unmodifiable. 回答1: This isn't possible as far as I know. There is however a method