I have created an Array List in Java that looks something like this:
public static ArrayList error = new ArrayList<>(); for (int x= 1
You can write like this.
String output = errors.toString().replaceAll("(^\\[|\\]$)", "");