So... either table is null, or table.getSelectionModel() is null, or table.getSelectionModel().getSelectedItem() is null. But it seems that you've already homed in on the reason:
Ertan Hasani wrote:I thought that the error was because when the program starts none of them is selected
In other words, table.getSelectionModel().getSelectedItem() is null because no item in the table is selected. You're going to have to decide what that "merrId()" method should do if that is the case. It seems like you tried to force an item to be selected, but I wouldn't have done that because it could happen that the table is empty and there are no items to be selected.
You could have the method return null if no item is selected, for example. Or if that's a serious situation which should not happen then you could throw an exception.
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads