Tagged articles
5 articles
Page 1 of 1
Architect's Guide
Architect's Guide
Jun 2, 2024 · Fundamentals

Pitfalls and Best Practices of Arrays.asList and ArrayList.subList in Java

This article explains how Java's Arrays.asList creates a fixed‑size list that throws UnsupportedOperationException on add/remove, and how ArrayList.subList returns a mutable view whose non‑structural changes affect both the original list and the sublist while structural changes can trigger ConcurrentModificationException, providing code examples and practical guidelines.

Arrays.asListCollectionsConcurrentModificationException
0 likes · 9 min read
Pitfalls and Best Practices of Arrays.asList and ArrayList.subList in Java
Java Architect Essentials
Java Architect Essentials
Mar 19, 2023 · Backend Development

Why Arrays.asList and subList Can Throw Unexpected Exceptions in Java

This article explains the hidden pitfalls of Java's Arrays.asList and ArrayList.subList methods, showing how fixed‑size lists cause UnsupportedOperationException, how subList creates a mutable view that can trigger ConcurrentModificationException, and provides concrete code examples and source‑code analysis.

Arrays.asListConcurrentModificationExceptionJava
0 likes · 10 min read
Why Arrays.asList and subList Can Throw Unexpected Exceptions in Java
Top Architect
Top Architect
Mar 29, 2021 · Fundamentals

Pitfalls of Using Arrays.asList and ArrayList.subList in Java

This article explains common traps when using Java's Arrays.asList and ArrayList.subList methods, including why add operations throw UnsupportedOperationException, how subList creates a view that shares modifications with the original list, and the circumstances that lead to ConcurrentModificationException.

Arrays.asListConcurrentModificationExceptionUnsupportedOperationException
0 likes · 8 min read
Pitfalls of Using Arrays.asList and ArrayList.subList in Java
Java Captain
Java Captain
Mar 27, 2021 · Fundamentals

Pitfalls of Using Arrays.asList and ArrayList.subList in Java

This article explains common pitfalls when using Java's Arrays.asList and ArrayList.subList methods, illustrating why add operations cause UnsupportedOperationException, how subList creates a view that shares modifications with the original list, and provides best‑practice recommendations to avoid runtime errors.

Arrays.asListConcurrentModificationExceptionJava
0 likes · 8 min read
Pitfalls of Using Arrays.asList and ArrayList.subList in Java
Java Backend Technology
Java Backend Technology
Jan 24, 2021 · Fundamentals

Why Arrays.asList and subList Can Throw Unexpected Exceptions in Java

This article explains common pitfalls when using Java's Arrays.asList and ArrayList.subList methods, illustrating why add operations may trigger UnsupportedOperationException or ConcurrentModificationException, and provides guidance on safe usage to avoid runtime errors in production.

Arrays.asListCollectionsConcurrentModificationException
0 likes · 10 min read
Why Arrays.asList and subList Can Throw Unexpected Exceptions in Java