Why the method with byte, not work?
cuestion
Resolved
Comments (3)
- Popular
- New
- Old
You must be signed in to leave a comment
Chris Hilborne
14 April 2020, 16:47solution
Because 1 is an int -- so rather than narrowing it's type (thereby changing the value of 1) the complier will widen it to the next variable type available as a parameter for the method, in this case long.
+2
Sherry Li
10 May 2020, 03:04
may I know why the answer is not float? float could also compile.
0
PeterC Android Developer
1 January 2022, 16:15
Float goes AFTER long in the widening chain.
... -> int -> long -> double -> float
0