The following code is giving the compilation error.When I try to add Long and Integer ,then it is giving the error. I do not the rules for adding these wrapper classes.Can you provide me link if it is already there and also link to read on wrapper operations.
Hi, I think your question was Long l=5; fails to compile and shows the below error Type mismatch: cannot convert from int to Long The constant 5 will be autoboxed to a new Integer object and assigned to Long which will cause a error. You will get an errror for all bold below
All wrapper classes are child classes of Number class and as you know you cannot assign child classes to each other. For example we know String and Integer are child classes of Object but we cannot assign a Integer to String and vice versa. Hope this clears your doubt Thanks, Deepak