public class Tester { static void test(float x) { System.out.print("float"); } static void test(double x) { System.out.print("double"); } public static void main(String[] args) { test((float) 99.9); } }
static void test(float x) {
System.out.print("float");
}
static void test(double x) {
System.out.print("double");
public static void main(String[] args) {
test((float) 99.9);
99.9 is a double not a float
to print “float” cast 99.9 to (float)
Oracle Certified Professional Java Programmer
Access: Public Instant Grading
Jobilize.com uses cookies to ensure that you get the best experience. By continuing to use Jobilize.com web-site, you agree to the Terms of Use.