Java Tutorial/Collections/Prebuilt Collections

Материал из Java эксперт
Перейти к: навигация, поиск

Empty Collections

The Collections class provides three constants to represent empty collections



public static final List EMPTY_LIST
public static final Map EMPTY_MAP
public static final Set EMPTY_SET





Singleton Collections

import java.util.Collections;
public class MainClass{
  public static void main(String[] a){
     System.out.println(Collections.singletonList("a")); 
     System.out.println(Collections.singleton("a"));
     System.out.println(Collections.singletonMap("a","b"));
  
  }
}



[a]
[a]
{a=b}