public class Tester { public static void main(String[] args) { Long var = (long) 999; // Line 3 long x1 = var.longValue(); // Line 5 double x2 = var.longValue(); // Line 7 double x3 = (double) var.longValue(); // Line 9 Double x4 = Long.valueOf("999"); // Line 11 Number x5 = Integer.parseInt("999"); // Line 13 Long x6 = Integer.parseInt("999"); // Line 15 } }
public static void main(String[] args) {
Long var = (long) 999; // Line 3
long x1 = var.longValue(); // Line 5
double x2 = var.longValue(); // Line 7
double x3 = (double) var.longValue(); // Line 9
Double x4 = Long.valueOf("999"); // Line 11
Number x5 = Integer.parseInt("999"); // Line 13
Long x6 = Integer.parseInt("999"); // Line 15
}
the right hand side returns a Long which cannot be widen to a Double
Long x6 = Integer.parseInt("999");
the right hand side returns an int value which be wrapped to an Integer but cannot be widen to a Long
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.