简体   繁体   中英

toString() Error, Cannot resolve method toString()

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM