y
02/08/2023, 3:32 PMList.asReversed()
construct a copy, or is it an “efficient” operation?Sam
02/08/2023, 3:32 PMy
02/08/2023, 3:33 PMSam
02/08/2023, 3:34 PMy
02/08/2023, 3:36 PMephemient
02/08/2023, 4:48 PMto…()
might not create a copy, but the difference should not be observable (unless you're comparing instances)y
02/08/2023, 4:49 PMMap<K, V>.toSortedMap()
would certainly have (some) runtime costephemient
02/08/2023, 4:52 PMMap
is not immutable, since MutableMap
is a subtypeephemient
02/08/2023, 4:52 PMephemient
02/08/2023, 4:56 PMString.toString()
doesn't return a copy, it returns the String
instance itself. it could create a copy, but since you can't change any state in String
, there is no observable behavior difference whether it's a copy or a view (not counting performance and not counting comparing instances with ===
)ephemient
02/08/2023, 4:58 PMString.substring
from a view to a copy in Java 7, which changed performance and memory usage characteristics, but again, since String
is immutable, it's not an observable difference as far as we usually care abouty
02/08/2023, 5:03 PM