as it is Treeset. So, before inserting any new object (in this case number) it will compare with the previous object and then will insert.
The previous object is of Integer type and we are inserting short type which will ultimately autobox to Short. Comparison is ok. but
at the time of insertion Short into generic type of Integer will not allow as Integer and Short are are siblings under wrapper class and can't be casted to each-other.
Hello Prakash Mahto,
Actually it does not matter whether you use TreeSet or not..
variable number is correctly autoboxed to Short but
all wrapper classes are peers to one another so the compiler complains.