top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

While passing a Collection as argument to a function, how can we make sure the function will not be able to modify it?

+1 vote
744 views
While passing a Collection as argument to a function, how can we make sure the function will not be able to modify it?
posted Mar 14, 2016 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

We can create a read-only collection using Collections.unmodifiableCollection(Collection c) method before passing it as argument, this will make sure that any operation to change the collection will throw UnsupportedOperationException.

answer Mar 16, 2016 by Karthick.c
Similar Questions
0 votes

There is a possibility on one controller multiple people are working and all of them have login credentials of controller node. Assume someone is editing one playbook but he/she does not let others to see the changes. Is there any way in Ansible by which a user can stop others to edit/read the file ?

...