I am trying to convert the int id I get back from a model called Part in a search functionality I am building to a string so I can simplify the search.
Here is the if statement I have used so far:
if(part.getId().toString().indexOf(searchText) > -1) {
return true;}
When I try to convert this id to a string, I am shown an error that says Cannot resolve method toString()
Here is the get method in the Part model I am using:
public int getId() { return id; }
Not sure what I am doing wrong here?
I am using JavaFX 11
You can't call a method on primitive types like double, int, float in Java.
Use String.valueOf(part.getId()) instead.
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