I have started using the method reference operator :: in java.
I am basically adding a Clipboard listener to the clipboard manager like this:
this.clipboardManager.addPrimaryClipChangedListener(this::doSomething);
but since this way I don't get a reference to the listener I have just added, how would I remove the listener then?
Like this?
this.clipboardManager.removePrimaryClipChangedListener(this::doSomething);
You're adding an anonymous class and then trying to remove a separately created anonymous class, that doesn't exist.