Implicit casting of primitives happens only in assignment and not in method argument passing.
Short s = 7;(fine)
public void junk(short s){} and junk(7) will error. This is fine because in former case, we know the target type to which the casting is to be done. But in the latter case we don't know the target type to be casted to(in case there are multiple overloaded junk methods).
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment