Skip to content
Advertisement

Lambda compareTo() not being recognized

JavaScript

I’m creating an endpoint to list just a single object with findById, and using lambda to go through the list and find the id, but the terminal is acusing an error because of the compareTo(id) part.

‘java: long cannot be dereferenced’

Need some help.

Advertisement

Answer

well id is long, so you should use == instead of .compareTo()

JavaScript

Or “box” the id using Long.valueOf(id)

…btw, maybe you should use .equals() instead of .compareTo() == 0

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement