Explain the syntax of Collections.emptyList()

后端 未结 5 1874
故里飘歌
故里飘歌 2020-12-24 01:35

I just studied about generic programming, the List interface, and ArrayList, so I can understand the statement below.

Arra         


        
5条回答
  •  没有蜡笔的小新
    2020-12-24 02:07

    1.Collection is an interface and collections is a static class consists exclusively of static methods that operate on or return collections. Hence we cannot use Collections or Collections.

    2. before emptyList(used to get the empty list that is immutable) denotes that only String values can be added to it. Like:

    list2.add("A");
    list2.add("B");
    

    3.The statement means that it will create a immutable empty list of type List.

    You can check out this link: Difference between Java Collection and Collections

提交回复
热议问题