K
K
kurrbanov2020-12-03 20:58:30
Java
kurrbanov, 2020-12-03 20:58:30

Why can't an ArrayList store primitive types internally?

For example, why can't you use , why can it only store a "wrapper class" inside itself?ArrayList<int>ArrayList<Integer>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg Carp, 2020-12-03
@Rebel-Cat

Apparently, in order not to complicate life, ArrayList accepts Object[], in any case, adding an Integer value to the list, you use the primitive types list.add(1), which are autoboxed in Objects

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question