I am writing my own implementation of TableModel . Since I will need several different implementations that share some functions, I decided to prepare an abstract class first. The fields of the table are:
protected Object[][] lines;
Basically, all the elements in one column should be of the same type, however, the classes of columns can vary in different implementations. I would like to write a generic setValueAt function in an abstract class, checking if val correct type or not.
@Override public void setValueAt(Object val, int row, int col) { if (val instanceof this.getColumnClass(col)) lines[col][row] = val; }
Compiler Error:
Syntax error on token "instanceof", == expected
Why?
source share