int a = Math.max( 5, (long) 5); System.out.println(a);
test.java:31: possible loss of precision found : long required: int int a = Math.max( 5, (long) 5);
if we go with long ...no prob
long a = Math.max( 5, (long) 5); System.out.println(a);
we checked it in indirect way...
Joined: Mar 13, 2004
While a primitive variable's type may be saved in a debugging symbol table (javac -g), the type of an expression is a compile-time notion, so there is nothing to test at execution time.
You can look at the generated bytecode with javap and see what the compiler did with your expression. In this case, it's pretty obvious that Java created bytecode for a long expression. Try it yourself. [ April 12, 2005: Message edited by: Mike Gershman ]