static < E > ImmutableList < E > asImmutableList ( Object [ ] elements , int length ) { switch ( length ) { case 0 : return of ( ) ; case 1 : return of ( ( E ) elements [ 0 ] ) ; default : if ( length < elements . length ) { elements = Arrays . copyOf ( elements , length ) ; } return new RegularImmutableList < E > ( elements ) ; } }
Views the array as an immutable list . Copies if the specified range does not cover the complete array . Does not check for nulls .