I have an ArrayList of String arrays which is added to like so:
List data = new ArrayList<>();
data.add(new String[] {var, lex, valor});
>
remove
by String array will not work, as list.remove
calls equals()
on the object. In case of array.equals it is just reference comparison (==
).
Remove by position works and you have to specify the right index as primitive int
.
public void eliminarPos(String var, String lex, String valor, int ii) {
String[] uno=data.remove(ii);
System.out.println(uno);
}