Languages
[Edit]
EN

Java - immutable ArrayList in Java

4 points
Created by:
Tomeriko
413

In this short article, we would like to how in Java create immutable List - read-only list.

This technique can be used with all classes that implements List interface. Main advantage of this approach is: the list is only covered by class - list is not copied that makes solution very fast.

Quick solution:

 

Practical example

Edit

Output:

Note: in read-only list we are not able to do any modification.

Alternative titles

  1. Java - readonly ArrayList in Java
  2. Java - unmodifiable ArrayList in Java
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Java Collections - ArrayList

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join