Page 1 of 1

java warning to .format()

Posted: Fri Mar 04, 2022 6:50 pm
by seal58
Hi there,

I'm not really familiar with JAVA yet and try to convert a double to a string using format().
Compiler gives a warning. Nevertheless it works fine in my project.
Before that line the newString was ceated and initialized.
format-warning.jpg
format-warning.jpg (38.26 KiB) Viewed 1442 times
Should I change anything?

Re: java warning to .format()

Posted: Fri Mar 04, 2022 8:02 pm
by honki-bobo
format() is a static method, not an object method.

Try

Code: Select all

newString = String.format(%6.2f", value);

Re: java warning to .format()

Posted: Sat Mar 05, 2022 8:57 am
by seal58
That fixed it. Many thanks!