For these two variables, let’s say
char[] foo
(or int, float…) that foo.length == 1
and,
Character bar
(or Integer, Float…),
which foo[0]
and bar
have the same value, like bar = foo[0] = 'a';
. Then which one is better?
As the List’s generics only accept Object
and array “is something of Object
itself”, I doubt which one I should use in ArrayList, LinkedList… I would prefer performance instead of syntax, like someList.getLast()[0]
or someList.add(new char[] {'a'})
(let’s say someList
was declared before) looks bad, though, but I prefer this one.
Copilot said:
using wrapper objects is necessary despite the overhead compared to array
Did AI(Copilot) miss any point?
2