java - Casting an ImmutableList to List -


Although the research was going on in my circles, it seems that Google applies the Guava's ImmutableList list . So I can put it in the list , right? I know that if any modification methods of the list are used, but can that be all wrong?

  Public listing & lt; Integer & gt; GetList () {Return ImmutableList.of (1,2,3); }  

If this list is enforced, then insert it into the list There is no requirement . You can assign it to the list variable or put it next to a method which list without any castings

and, Yes, any methods that modify the list throws an exception, but whether or not you put it on the list .


Comments