79583483

Date: 2025-04-20 15:16:08
Score: 0.5
Natty:
Report link

What a difference?

subList takes less memory as it refers at the same original list but with boundaries to view (fromIndex, toIndex).No matter what changes you are doing in subList or in that part of original list - they both are changes because essentially they refers to the same memory.

slice allocate new List in memory. It means that you can modify new sliced list and it doesn't affect original List: add or remove elements, replace an element with new one (mutable list). The only exception: if you modified an element - it is modified in both original and sliced lists, because they refer to the same element in the memory.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Starts with a question (0.5): What a
  • Low reputation (0.5):
Posted by: Alexey Simchenko