I know that java(c?) can box and unbox types and convert between primitive types when necessary, but why does it not want to do that both at the same time.
For example if I were to do this:
ArrayList<Byte> bytes = new ArrayList<>();
bytes.add(8);
Javac will panic and tell me Collection.add(Byte)
is not applicable, but were I to use ArrayList<Integer>
instead it would not be a problem.
If I would do byte aByte = 8; bytes.add(aByte);
it would also compile fine.
Why is this, is there a good reason for this?