I am having a Map of type HashMap.
I am trying to iterate over the map and for every entry, for which the boolean flag is set to true, I am trying to print the corresponding key value.
I am able to achieve this. However, instead of printing the String “key” values, it prints String objects. I tried casting it, using the .toString() function. Nothing solved it.
Any help would be greatly appreciated.
Thanks,S.
Your followup suggests that the values in your Map are not of type String and are not of a type that has overridden toString, which is why, when you call toString, you get a value like “com.f5.lunaui.emproto.reports.Device_Sri@334003”.
In Device_Sri, you should override the toString method to return the String you want:
Of course, you’ll probably want to calculate the value “em_device90-36” from the fields of the Device_Sri class.