Can anyone please let me know how to remove duplicate values from
String s=\"Bangalore-Chennai-NewYork-Bangalore-Chennai\";
and output sh
Just the idea:
Collection
Collection
and erase duplicatesCollection
to build the new stringThe most tricky part should be 3, but not impossible. If you use a Set
, you can skip this step.
EDIT maybe you can substitute 2&3 with a presence check before adding the element