I have a string like this:
String line="[x1,x2,x3]";
I want to remove both of the square brackets from the String (replace them with an empty string). I tried it like this:
String x=line.replace("[","").replace("]","");
Is there a more efficient way than this?
null- please clarify.x=line.replaceAll("^\\[|\\]$", "").