Immutability of the Slice Versus the Elements

This lesson explains immutability of the slice versus the elements and use of immutability in general.

We have seen earlier in this chapter that the type of an immutable slice has been printed as immutable(int[]). As the parentheses after immutable indicate, it is the entire slice that is immutable. Such a slice cannot be modified in any way; elements may not be added or removed, their values may not be modified and the slice may not be changed to provide access to a different set of elements:

Get hands-on with 1200+ tech skills courses.