Without replaceall Output: [3, 2, 1]
With replaceall Output: 3,2,1
Is there anyway to do this using single replaceAll method, something like
set.toString().replaceAll("\\[\\]\\s+","");
Now Code
Set<String> set = new HashSet<String>();
set.add("1");
set.add("2");
set.add("3");
System.out.println(set.toString().replaceAll("\\[", "").replaceAll("\\]", "").replaceAll("\\s+", ""));