The class you are working on contains method with signature setText(String value)
but there's no method with signature setText(Double value)
.
When you call a method compiler checks the parameter type and tries to recognize what method should be in use for this case.
As you are using Double
type for the parameter, the compiler is unable to find a method with signature setText(Double value)
and you get the error you have reported in your question.
To overcome this issue, convert your parameter from Double
to String
type before passing it to setText
method.
txtRate.setText(String.valueOf(emp.getRate()));
or
txtRate.setText(emp.getRate().toString());
But the second approach may throw NullPointerException
if emp.getRate()
returns null, so the first approach is safer.
In case you want to format your numbers in a fancy way, consider this tutorial: https://docs.oracle.com/javase/tutorial/java/data/numberformat.html