Friday, 10 July 2015

Java : Collection Framework : Collections (emptyList)


Click here to watch in Youtube :
https://www.youtube.com/watch?v=loy0Jduw3Oc&list=UUhwKlOVR041tngjerWxVccw

Click the below Image to Enlarge
Java : Collection Framework : Collections (emptyList)
Java : Collection Framework : Collections (emptyList)
Java : Collection Framework : Collections (emptyList)
CollectionsExample.java

import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;

/*
 Example of:  

 Method:

 emptyList() 

 Returns:

 an empty immutable list.
------------------------------
 Method:

 emptySet()

 Returns:

 the empty set.
-----------------------------
 Method:

 emptyMap()

 Returns:

 the empty map

 */

public class CollectionsExample
{

    public static void main(String[] args)
    {

        /*
         * Returns an empty list (immutable).
         */
        List<String> emptyList = Collections.emptyList();
        System.out.println("emptyList : " + emptyList);

        /*
         * Returns an empty set (immutable).
         */
        Set<String> emptySet = Collections.emptySet();
        System.out.println("emptySet : " + emptySet);

        /*
         * Returns an empty map (immutable).
         */
        Map<String, String> emptyMap = Collections.emptyMap();
        System.out.println("emptyMap : " + emptyMap);

    }

}
Output
emptyList : []
emptySet : []
emptyMap : {}
To Download CollectionsDemoEmptyList Project Click the below link
https://sites.google.com/site/javaee4321/java-collections/CollectionsDemoEmptyList.zip?attredirects=0&d=1

See also:

  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • No comments:

    Post a Comment

    Google+ Followers

    Google+ Badge