Home  >  Forum  >  Core Java
Post New Query

java.lang.IllegalArgumentException: Map is non-empty



Asked on May 26, 2013
Hi All,

I am trying to run Collections.newSetFromMap but got below error, any clue from java folks.

Exception in thread "main" java.lang.IllegalArgumentException: Map is non-empty
at java.util.Collections$SetFromMap.<init>(Unknown Source)
at java.util.Collections.newSetFromMap(Unknown Source)




Replied on May 26, 2013
      you have to declare argument in Collections.newSetFromMap like this
Collections.newSetFromMap(new HashMap<Object,Boolean>())
You need to keep Collections.newSetFromMap argument as empty.



Replied on May 26, 2013
Collections.newSetFromMap should not be used for TreeMap or HashMap as they already implement set, it should be used for WeakHashMap etc 

Write Answer







©2019 concretepage.com | Privacy Policy | Contact Us