Guava

作者: 贾尼 | 来源:发表于2017-12-12 17:37 被阅读0次
    • ImmutableList

    用ImmutableList构建List:

    import com.google.common.collect.ImmutableList;
    import org.junit.Test;
    
    import java.util.List;
    
    import static org.junit.Assert.assertEquals;
    
    public class ImmutableListStudyTest {
    
      @Test
      public void test_Immutable_List() throws Exception {
        List<Object> params = ImmutableList.builder()
                .add(1)
                .add("2")
                .add(3L)
                .build();
    
        assertEquals(params.get(0), 1);
        assertEquals(params.get(1), "2");
        assertEquals(params.get(2), 3L);
      }
    }
    

    compile group: 'com.google.guava', name: 'guava', version: '23.5-jre

    相关文章

      网友评论

          本文标题:Guava

          本文链接:https://www.haomeiwen.com/subject/remnixtx.html