Why can't I have 'int' as the type of an ArrayList?

前端 未结 7 737
时光取名叫无心
时光取名叫无心 2020-12-05 06:17

I want to declare an ArrayList of type int.

Why does the following give me an error:

ArrayList list1 = new Array         


        
7条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-05 07:19

    int is a primitive data type but Integer is a class so an arrayList array can only take reference types as its parameter not primitive type

提交回复
热议问题