I am currently having a little problem removing a string from an array list. Code is as follows:
String selectedCol = req.getParameter("col");
if (selectedCol != null) {
ArrayList < String > ar = new ArrayList < String > ();
String removeColumn = layout.getColumn(selectedCol).getName();
String layOut = "layout." + key + "." + layout.getName() + ".group";
List < String > list = Arrays.asList(props.getProp(layOut, null).replace("[", "").replace("]", "").split(","));
ar.addAll(list);
ar.removeAll(Arrays.asList(removeColumn));
props.putString(layOut, ar.toString().trim());
}
so array "ar" populates the following:
[contact, created]
I thought it could be the list size which could be incorrect however it shows up with the correct size when I do ar.size()
The following variable:
removeColumn
is populated with "created".
I have tried the following:
ar.removeAll(Arrays.asList(removeColumn));
and
ar.remove(removeColumn);
which should result in:
[contact]
however using removeall or remove did not work. I am trying to achieve this without the need of looping through.
Help?