java9 create read-only arrays

Before java9 way to create read-only collection of

        With static method Collections provided by operations:

  • Create a read-only List
   public static <T> List<T> unmodifiableList(List<? extends T> list)

      

  • Create a read-only Set
   public static <T> Set<T> unmodifiableSet(Set<? extends T> s) 

        

  • Create a read-only Map

        public static <K,V> Map<K,V> unmodifiableMap(Map<? extends K, ? extends V> m)

        

java9 create a read-only collection after

Static methods use the interface provided by the byte of (), a series of overloads the method.

Published 44 original articles · won praise 17 · views 2449

Guess you like

Origin blog.csdn.net/weixin_40391011/article/details/104073802