1. 'var' è una stringa e le stringhe non si confrontano con == ma con equals. Oppure converti la stringa in intero.
2.
codice:
public int get(String var) thorws IllegalArgumentException {
int tmp = -1;
for(int i = 0; i < memElements.size(); i++) {
if(memElements.get(i).getVar() == Integer.parseInt(var)) {
tmp = memElements.get(i).getVal();
}
}
if (tmp == -1) {
throw new IllegalArgumentException();
}
return tmp;
}
Però non ha molto senso lanciare un eccezione, sarebbe meglio restituire il -1 :master: