While performing the following:
ImmutableMultimap<Something, Something> map;
//Say I insert "Hello", "5" to the map
System.out.println(map.keys().toString());
This prints [Hello]
So when I do
if(map.keys().toString().equals("Hello"))
it always fails. I don't want to do
if(map.keys().toString.equals("[Hello]")
Is there a way to display the result without the square brackets?
You should never ever use toString()
for anything serious! This method is meant for people inspecting what's going on (e.g. in debugger) and for nothing else.
Moreover, there are no brackets there in. map.keys()
is a collection and it's toString()
method works like it should for collections. You'd better replace your test by testing map.keys.size() == 1
and then checking the only element.