I ran the following and I did not have this problem. Are you getting an error from checking Eclipse code or from a Java compiler?
public class TestDouble { public static void main(String[] args) { double x = 7.0; System.out.printf("%.2f", x); } }
This will also work and may stop Eclipse from complaining:
public class TestDouble { public static void main(String[] args) { double x = 7.0; System.out.printf("%.2f", new Double(x)); } }
source share