I have edited my example to show a more practical example of what I'm trying to achieve. I would like to understand what I should specify as the second type when instantiating the new TableCell object within the Lambda expression, given the types being passed into the method.
Thanks in advance for any help.
void setTableCellStuff (TableColumn <Object, ?> tableCell) {
tableCell.setCellFactory(arg0 ->
new TableCell <Object, ?> () // cannot use ? in instantiator.
);
}
You probably want this:
<T> void setTableCellStuff (TableColumn <Object, T> tableCell) {
tableCell.setCellFactory(arg0 ->
new TableCell <Object, T> ()
);
}
T could still be any type, but this way the type of table cell you construct matches the type of column you have.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With