Java Reference
In-Depth Information
Returns
true
if the two given collections have no elements in
common.
There are numerous methods for working with lists:
public static <T> boolean
replaceAll(List<T> list, T oldVal, T
newVal)
Replaces all occurrences of
oldVal
in the list with
newVal
.
Returns
true
if any replacements were made.
public static void
reverse(List<?> list)
Reverses the order of the elements of the list.
public static void
rotate(List<?> list, int distance)
Rotates all of the elements in the list by the specified distance.
A positive distance moves elements toward the end of the list,
wrapping around to the beginning. A negative distance moves
elements toward the head of the list, wrapping around to the
end. For example, given a list
v, w, x, y, z,
a rotate with dis-
tance 1 will change the list to be
z, v, w, x, y
(as will a rotation
of 6, 11, … or 4, 9, …).
public static void
shuffle(List<?> list)
Randomly shuffles the list.
public static void
shuffle(List<?> list, Random randomSource)
Randomly shuffles the list using
randomSource
as the source of
public static void
swap(List<?> list, int i, int j)