In a game that I am making, I have a look in my game which goes through an array, and lists the things in the arraypublic void listOpen() {    ArrayList<String> open = main.getOpenable();    for(int i = 0; i < open.size(); i++) {        String value = open.get(i);        textWindow.append(value + \n);        error.setScroll();    }}Sometimes when I'm running the program I notice that it lags slightly. Is there anyway I can make it more efficient?
Displaying items of a list in a text window
java;performance
Make only one textWindow.append() operation and consider using StringBuilder, to construct string to append.public void listOpen() {    ArrayList<String> open = main.getOpenable();    StringBuilder appendBuilder = new StringBuilder();    for(int i = 0; i < open.size(); i++) {        String value = open.get(i);        appendBuilder.append(value).append(\n);        error.setScroll();    }    textWindow.append(appendBuilder.toString());}