Hello Friends,
I came across this weird observation(or may be,i'm the only one finding this weird,point me out if that is the case)
In
java,
we can write the following:
(until the int is well in range of byte)
even though it is an int and no explicit casting is required (like the one required when you write:
(even though 14 is well in range of int))
The same is true for short and char.
However if i write a code like this:
i get compilation error saying : fount int but required short....
Why is it the case?
You can assign int(well in range of short) directly to a short variable but you can't pass an int to a short variable, what does that mean? Why is the contradiction coming?
Does it mean rules of assignments and rules of passing values between functions are different.
If that is the case, it is disguisting, i'm studying java and i have found so much of such things, do i need to remember them as exception....
Help!!!