Click here to watch in Youtube :
https://www.youtube.com/watch?v=MgVaU38yUMg&list=UUhwKlOVR041tngjerWxVccw
HashMapExample.java
Output
https://www.youtube.com/watch?v=MgVaU38yUMg&list=UUhwKlOVR041tngjerWxVccw
HashMapExample.java
import java.util.HashMap; /* * Example of isEmpty() method. */ public class HashMapExample { public static void main( String[] args ) { HashMap<Integer, String> hashMap = new HashMap<Integer, String>(); System.out.println("hashMap : " + hashMap ); /* * Returns true if this map contains no key-value mappings. */ boolean isEmpty = hashMap.isEmpty(); System.out.println("isEmpty : " + isEmpty + "\n"); hashMap.put(1, "Apple"); hashMap.put(2, "Ball"); hashMap.put(3, "Cat"); System.out.println("hashMap : " + hashMap ); isEmpty = hashMap.isEmpty(); System.out.println("isEmpty : " + isEmpty); } }
hashMap : {} isEmpty : true hashMap : {1=Apple, 2=Ball, 3=Cat} isEmpty : false
https://sites.google.com/site/javaee4321/java-collections/HashMapDemoIsEmpty.zip?attredirects=0&d=1
See also:
No comments:
Post a Comment