dictionary - java.lang.ClassCastException: java.util.HashMap$EntrySet cannot be cast to java.util.Map$Entry -
i have overrriden method this
@override public build auth (map.entry<string, string> auth) { this.mauth = auth; return this; }
here trying call method in following way
map<string, string> authentication = new hashmap<string , string> (); authentication.put("username" , "testname"); authentication.put("password" , "testpassword"); map.entry<string, string> authinfo =(entry<string , string>) authentication.entryset(); authmethod.auth(authinfo)
while running getting
java.lang.classcastexception: java.util.hashmap$entryset cannot cast java.util.map$entry
how can pass map.entry<string, string>
auth method
you trying cast set single entry.
you can use each entry item iterating set:
iterator = authentication.entryset().iterator(); while (it.hasnext()) { map.entry entry = (map.entry)it.next(); //current entry in loop /* * each entry */ }
Comments
Post a Comment