Java
T
point
Home
Python
Java
JavaScript
HTML
SQL
PHP
C#
C++
DS
Aptitude
Reasoning
Selenium
DBMS
C
Android
Interview Q
Content Menu ▼
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Question 1
:
How do you get immutable object of a collection ? For example if you were to write an API which return a List or a Set or a Map when a method is called, but you also want that you don´t want the client of your API to add or delete any object in the returned collection ?
1.
Use Collections.immutableCollection() method.
2.
Use the Collections.unmodifiableXxxx() method with the collection as an argument,which returns an immutable object of specific type.