Home  >  Forum  >  Core Java
Post New Query

java.lang.IllegalArgumentException: Map is non-empty

joined on
May 23,2013
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)

joined on
March 14,2013
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.
joined on
March 14,2013
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


Copyright ©2017 concretepage.com, all rights reserved |Privacy Policy | Contact Us