Understand the limits of autoboxing, e.g., why Character [] C = new char [] { ’ a ’ , ’b’}; will not compile

#1

I was unable to understand this line in chapter on Primitive Types(Pg 45):

Understand the limits of autoboxing, e.g., why Character [] C = new
char [] { ’ a ’ , ’b’}; will not compile.

I want to know the reason behind this and other limitations of autoboxing.

0 Likes

#2

Hi @abhishall,

In Java, arrays are reference types and there are no autoboxing for arrays. No boxing is required here.

Hope this helps!

0 Likes