I am referring Kathy & Sierra Book. I am stuck with a question on a assingment chapters' Self Test.
It has a following code...
What is the result :
B. A few
C. Compilation fails.
answer C is correct and book has following explanation for this
compilation fails. The var-args declaration is fine, but invade takes a short, so the argument 7 need to be cast to a short. with the cast, the answer is B, 'a few'
i dont understand y the compilation is failing and why do we have to cast it....argument 7 is well within the range of short limit.
and even if we require to cast how would we do it .
any help is much appreciated