How to make Java Arraylist Read-only? | Sololearn: Learn to code for FREE!

+1

How to make Java Arraylist Read-only?

11/28/2020 4:50:07 AM

Priyanka Gotugade.

3 Answers

New Answer

+5

Priyanka Gotugade. For more info you can visit this link,this link will helps you... https://www.google.com/amp/s/www.geeksforgeeks.org/how-to-make-an-arraylist-read-only-in-java/amp/

+3

Easiest way: List<String> immutable = List.of("I", "see", "fire"); See details in https://www.baeldung.com/java-immutable-list

0

Make list as final, you cannot change but only you can add...