# HG changeset patch # User smarks # Date 1535208403 -19800 # Sat Aug 25 20:16:43 2018 +0530 # Node ID fbb71a7edc1aeeb6065e309a3efa67bc7ead6a3c # Parent 9bf5205655ee3a8199abda638ad685b76a43a6fc 7033681: Arrays.asList methods needs better documentation Reviewed-by: smarks Contributed-by: jai.forums2013@gmail.com diff -r 9bf5205655ee src/java.base/share/classes/java/util/Arrays.java --- a/src/java.base/share/classes/java/util/Arrays.java Fri Sep 14 12:10:28 2018 -0400 +++ b/src/java.base/share/classes/java/util/Arrays.java Wed Sep 19 10:31:21 2018 -0700 @@ -28,6 +28,7 @@ import jdk.internal.HotSpotIntrinsicCandidate; import jdk.internal.util.ArraysSupport; +import java.io.Serializable; import java.lang.reflect.Array; import java.util.concurrent.ForkJoinPool; import java.util.function.BinaryOperator; @@ -4288,21 +4289,41 @@ // Misc /** - * Returns a fixed-size list backed by the specified array. (Changes to - * the returned list "write through" to the array.) This method acts - * as bridge between array-based and collection-based APIs, in - * combination with {@link Collection#toArray}. The returned list is - * serializable and implements {@link RandomAccess}. + * Returns a fixed-size list backed by the specified array. Changes made to + * the array will be visible in the returned list, and changes made to the + * list will be visible in the array. The returned list is + * {@link Serializable} and implements {@link RandomAccess}. + * + *
The returned list implements the optional Collection methods, except those + * that would change the size of the returned list. Those methods leave + * the list unchanged and throw {@link UnsupportedOperationException}. + * + * @apiNote + * This method acts as bridge between array-based and collection-based + * APIs, in combination with {@link Collection#toArray}. + * + *
This method provides a way to wrap an existing array: + *
{@code
+ * Integer[] numbers = ...
+ * ...
+ * List values = Arrays.asList(numbers);
+ * }
*
* This method also provides a convenient way to create a fixed-size * list initialized to contain several elements: - *
- * List<String> stooges = Arrays.asList("Larry", "Moe", "Curly");
- *
+ * {@code
+ * List stooges = Arrays.asList("Larry", "Moe", "Curly");
+ * }
+ *
+ * The list returned by this method is modifiable.
+ * To create an unmodifiable list, see
+ * {@link Collections#unmodifiableList Collections.unmodifiableList}
+ * or Unmodifiable Lists.
*
* @param